Im using RAD Studio... This is the code:
Somehow, every time i launched the compiled executable it seems to just recreate the mutex as if it was never created in the first place... Any Ideas?
Code
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("Unit1.cpp", Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
HANDLE mutex;
try
{
const char mutexname[] = "SingleInstanceProgram";
mutex = OpenMutex(0, false, mutexname);
if(mutex == NULL)
{
mutex = CreateMutex(NULL, true, mutexname);
}
else
{
ShowMessage("Application is already running.");
return 0;
}
Application->Initialize();
SetApplicationMainFormOnTaskBar(Application, true);
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
ReleaseMutex(mutex);
return 0;
}
//---------------------------------------------------------------------------Somehow, every time i launched the compiled executable it seems to just recreate the mutex as if it was never created in the first place... Any Ideas?








ty
- carpe noctem
