mirror of
https://github.com/EnderIce2/rpc-bridge.git
synced 2025-05-25 14:04:37 +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);
|
||||
}
|
||||
|
||||
print("(Steam) Starting service...\n");
|
||||
if (StartService(schService, 0, NULL) == FALSE)
|
||||
{
|
||||
if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
|
||||
{
|
||||
print("(Steam) Service is already running\n");
|
||||
CloseServiceHandle(schService);
|
||||
CloseServiceHandle(hSCManager);
|
||||
ExitProcess(0);
|
||||
}
|
||||
print("(Steam) Starting service and then exiting...\n");
|
||||
fclose(g_logFile);
|
||||
|
||||
print("StartService: %s\n", GetErrorMessage());
|
||||
MessageBox(NULL, GetErrorMessage(),
|
||||
"StartService",
|
||||
MB_OK | MB_ICONSTOP);
|
||||
ExitProcess(1);
|
||||
if (StartService(schService, 0, NULL) != FALSE)
|
||||
{
|
||||
CloseServiceHandle(schService);
|
||||
CloseServiceHandle(hSCManager);
|
||||
ExitProcess(0);
|
||||
}
|
||||
else if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
|
||||
{
|
||||
CloseServiceHandle(schService);
|
||||
CloseServiceHandle(hSCManager);
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
print("(Steam) Service started successfully, exiting...\n");
|
||||
CloseServiceHandle(schService);
|
||||
CloseServiceHandle(hSCManager);
|
||||
ExitProcess(0);
|
||||
MessageBox(NULL, GetErrorMessage(),
|
||||
"StartService",
|
||||
MB_OK | MB_ICONSTOP);
|
||||
ExitProcess(1);
|
||||
}
|
||||
else if (strcmp(argv[1], "--install") == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user