init
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#include "Base.h"
|
||||
#include "comm.h"
|
||||
#include "Mapping.h"
|
||||
#include "server_palpit.h"
|
||||
#include "server_pipe.h"
|
||||
#include "Gui.h"
|
||||
#include "XorStr.h"
|
||||
|
||||
#define MUTEX_NAME XOR_STRING_W(L"Local\\seriver_mutex_anit")
|
||||
|
||||
BOOL WINAPI CtrlHandler(DWORD type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CTRL_C_EVENT:
|
||||
case CTRL_BREAK_EVENT:
|
||||
case CTRL_CLOSE_EVENT:
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
RequestShutdown(XorStr("console ctrl"));
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
auto WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -> int
|
||||
{
|
||||
//AllocConsole();
|
||||
//freopen("CONOUT$", "w+", stdout);
|
||||
|
||||
HANDLE mutex = CreateMutex(nullptr, TRUE, MUTEX_NAME);
|
||||
if (!mutex || GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
if (mutex)
|
||||
CloseHandle(mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetConsoleCtrlHandler(CtrlHandler, TRUE);
|
||||
|
||||
Gui::CreateGuiWindow();
|
||||
|
||||
StartServer();
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
Reference in New Issue
Block a user