- 4


{

HKEY hKey;

DWORD dwIndex = 0;

DWORD VNameLength = REGVALUENAME_LENGTH;

char VName[REGVALUENAME_LENGTH];

DWORD dwLength = sizeof(struct TASKENTRY);

int i;

__try {

WaitForSingleObject(hConfigMutex, INFINITE);

//

for (i = 0; i < TASK_COUNT; i++) {

TaskTable[i].Active = FALSE;

TaskTable[i].ExecTime = 0;

ZeroMemory(&TaskTable[i].DllName, sizeof(TaskTable[i].DllName));

TaskTable[i].TermProc = NULL;

TaskTable[i].TaskThread = 0;

}

//

if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,

REGISTRY_TASKS_PATH,

0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) {

dwIndex = 0;

EntryCount = 0;

while (RegEnumValue(hKey,

dwIndex,

(char *)&VName,

&VNameLength,

NULL,

NULL,

(LPVOID)&TaskTable[dwIndex],

&dwLength) == ERROR_SUCCESS) {

if (dwLength != sizeof(struct TASKENTRY)) {

LogEvent(EVENTLOG_ERROR_TYPE, "Invalid Task Parameter");

break;

}

EntryCount+=1;

dwIndex+=1;

}

RegCloseKey(hKey);

} else LogEvent(EVENTLOG_ERROR_TYPE, "Error Loading Configuration");

}

__finally {

ReleaseMutex(hConfigMutex);

}

}

DoService.c

#include <windows.h>

#include "DoService.h"

#include "..\Comm.h"