···
BOOL CtestDialogApp::InitInstance()
{
char exeFullPath[MAX_PATH] = {0}; // MAX_PATH在API中有定义
int len=GetModuleFileNameA(NULL,
exeFullPath, //应用程序的全路径存放地址
MAX_PATH);
std::string path = exeFullPath; //配置文件名
path = path.substr(path.rfind("\")+1);
HANDLE hMutex = ::CreateMutex(NULL,TRUE,("Global\"+ path).c_str());
if(GetLastError() == ERROR_ALREADY_EXISTS || ERROR_ACCESS_DENIED == GetLastError())
{
MessageBox(NULL,"Has been running!","MT4 Manager Interface", MB_ICONEXCLAMATION );
return FALSE;
}
return FALSE;
}
···