||
看到别人是这样写的,小试一下,很好用
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("Main.cpp", MainForm);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
HANDLE hMutex = CreateMutex( 0, false, Application->Title.c_str() );
if ( hMutex )
{
if ( GetLastError() == ERROR_ALREADY_EXISTS )
{
CloseHandle(hMutex);
Application->Terminate();
}
}
try
{
Application->Initialize();
Application->CreateForm(__classid(TMainForm), &MainForm);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
CloseHandle(hMutex);
return 0;
}