First commit 11/12/1999
This commit is contained in:
45
CtrlDogs.cpp
Normal file
45
CtrlDogs.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#include <winuser.h>
|
||||
#include <winbase.h>
|
||||
|
||||
#pragma hdrstop
|
||||
USERES("CtrlDogs.res");
|
||||
USEFORM("CtrlDog.cpp", Dog);
|
||||
USEFORM("CtrlD_PasswordDlg.cpp", PasswordDlg);
|
||||
//---------------------------------------------------------------------------
|
||||
HINSTANCE g_hinst;
|
||||
//extern "C" __declspec(dllimport) int _stdcall RegisterServiceProcess( DWORD dwProcessID, int dwType);
|
||||
//function RegisterServiceProcess(dwProcessID, dwType: integer): integer; stdcall; external 'KERNEL32.DLL';
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
WINAPI WinMain(HINSTANCE, HINSTANCE hInstance, LPSTR, int)
|
||||
{
|
||||
AnsiString FsMutex = DateToStr(TDateTime::CurrentDate()) + AnsiString("-mutex-dog");
|
||||
|
||||
// RegisterServiceProcess(GetCurrentProcessID(), 1); // Hide Aplication
|
||||
// SetWindowLong(Application->Handle, GWL_EXSTYLE, XWndLong | WS_EX_TOOLWINDOW & ! WS_EX_APPWINDOW | WS_EX_TOPMOST);
|
||||
|
||||
HANDLE FhMutex = OpenMutex(MUTEX_ALL_ACCESS,False, FsMutex.c_str() );
|
||||
if ( FhMutex == 0 ) //it's a first instance
|
||||
{
|
||||
FhMutex = CreateMutex(NULL,false, FsMutex.c_str() );
|
||||
try
|
||||
{
|
||||
Application->Initialize();
|
||||
g_hinst = hInstance;
|
||||
Application->Title = "Sistema de Control";
|
||||
Application->CreateForm(__classid(TDog), &Dog);
|
||||
Application->ShowMainForm = false;
|
||||
Application->Run();
|
||||
}
|
||||
catch (Exception &exception)
|
||||
{
|
||||
Application->ShowException(&exception);
|
||||
}
|
||||
} else {
|
||||
if ( CloseHandle(FhMutex) ) FhMutex = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
Reference in New Issue
Block a user