firemail
标题:
常用功能
[打印本页]
作者:
Qter
时间:
2020-1-27 21:40
标题:
常用功能
获取应用程序路径
TCHAR exeFullPath[MAX_PATH]; // MAX_PATH
GetModuleFileName(NULL,exeFullPath,MAX_PATH);//得到程序模块名称,全路径
//解析路径,得到当前运行程序所在目录
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
_splitpath(strAppName, drive, dir, NULL,NULL);
CString strPath;
strPath.Format("%s%s", drive, dir);
//strPath即为得到的当前运行程序所在目录
char path[MAX_PATH];
GetCurrentDirectory(MAX_PATH,path);
bool AlreadyRunning;
CString strPath=path;
strPath = strPath + AfxGetApp()->m_pszExeName;
strPath.Replace("\\","_");
g_hMutexOneInstance = ::CreateMutex( NULL, TRUE, strPath);
AlreadyRunning = ( ::GetLastError() == ERROR_ALREADY_EXISTS ||
::GetLastError() == ERROR_ACCESS_DENIED);
欢迎光临 firemail (http://firemail.wang:8088/)
Powered by Discuz! X3