mirror of
https://github.com/EnderIce2/rpc-bridge.git
synced 2025-05-25 22:14:38 +00:00
Ensure log file is properly closed
* Closing the log before service starts prevents log file to be corrupted (like in #7)
This commit is contained in:
parent
8786efd144
commit
3a0b9ddb2a
36
main.c
36
main.c
@ -221,28 +221,26 @@ void HandleArguments(int argc, char *argv[])
|
|||||||
HeapFree(GetProcessHeap(), 0, asciiPath);
|
HeapFree(GetProcessHeap(), 0, asciiPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
print("(Steam) Starting service...\n");
|
print("(Steam) Starting service and then exiting...\n");
|
||||||
if (StartService(schService, 0, NULL) == FALSE)
|
fclose(g_logFile);
|
||||||
{
|
|
||||||
if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
|
|
||||||
{
|
|
||||||
print("(Steam) Service is already running\n");
|
|
||||||
CloseServiceHandle(schService);
|
|
||||||
CloseServiceHandle(hSCManager);
|
|
||||||
ExitProcess(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
print("StartService: %s\n", GetErrorMessage());
|
if (StartService(schService, 0, NULL) != FALSE)
|
||||||
MessageBox(NULL, GetErrorMessage(),
|
{
|
||||||
"StartService",
|
CloseServiceHandle(schService);
|
||||||
MB_OK | MB_ICONSTOP);
|
CloseServiceHandle(hSCManager);
|
||||||
ExitProcess(1);
|
ExitProcess(0);
|
||||||
|
}
|
||||||
|
else if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
|
||||||
|
{
|
||||||
|
CloseServiceHandle(schService);
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
ExitProcess(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
print("(Steam) Service started successfully, exiting...\n");
|
MessageBox(NULL, GetErrorMessage(),
|
||||||
CloseServiceHandle(schService);
|
"StartService",
|
||||||
CloseServiceHandle(hSCManager);
|
MB_OK | MB_ICONSTOP);
|
||||||
ExitProcess(0);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "--install") == 0)
|
else if (strcmp(argv[1], "--install") == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user