这个好办:
CreateMutex(NULL,true,"MyApp");
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
ShowMessage("The program is runing.......");
Application->Terminate();
}
If the function succeeds, the return value is a handle to the mutex object. If the named mutex object existed before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS. Otherwise, the caller created the mutex.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.