-
Notifications
You must be signed in to change notification settings - Fork 0
/
TilchiAgent.cpp
48 lines (47 loc) · 1.2 KB
/
TilchiAgent.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//$$---- EXE CPP ----
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("MainFormClass.cpp", MainForm);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
// check for the existence of the mutex.
HANDLE Mutex = OpenMutex(MUTEX_ALL_ACCESS, false, "OneInstanceAllowed");
if (Mutex == NULL) // this is the only instance
{
//create the mutex...
Mutex = CreateMutex(NULL, true, "OneInstanceAllowed");
}
else // this is not the only instance
{
return 0;
}
Application->Initialize();
Application->ShowMainForm = false;
Application->CreateForm(__classid(TMainForm), &MainForm);
Application->Run();
// release the mutex...
ReleaseMutex(Mutex);
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------