c++builder防止程序重复运行 转贴
时间:2011-04-12 来源:hanny
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
HANDLE hMutex=CreateMutex(NULL,false,"RunOnlyOneInstance");
if(hMutex==NULL||ERROR_ALREADY_EXISTS==::GetLastError())
{
return false;
}
Application->Initialize();
Application->Title = "";
Application->CreateForm(__classid(TfmMain), &fmMain);
Application->CreateForm(__classid(Tdm), &dm);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
相关阅读 更多 +