if (hStatus ==
(SERVICE_STATUS_HANDLE)0)
{
WriteToLog("Registering Control Handler failed!");
return;
}
int error = InitService();
if (error)
{
// Initialization failed
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = -1;
SetServiceStatus(hStatus, &ServiceStatus);
return;
}
// We report the running status to SCM.
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
ServiceStatus.dwWin32ExitCode = NO_ERROR;
ServiceStatus.dwServiceSpecificExitCode = NO_ERROR;
SetServiceStatus (hStatus, &ServiceStatus);
MEMORYSTATUS memory = { 0 };
// The worker loop of a service
while (ServiceStatus.dwCurrentState
== SERVICE_RUNNING)
{
//char buffer[16] = { 0 };
//GlobalMemoryStatus(&memory);
//sprintf(buffer, "%d", memory.dwAvailPhys);