- 2


void RegEventSource()

{

HKEY hk;

DWORD dwData;

UCHAR szBuf[80];

if (RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\

\\EventLog\\Application\\CommServ", &hk)) {

printf("could not create registry key");

return;

}

/* Set the Event ID message-file name. */

strcpy(szBuf, "c:\\ibserver\\bin\\CommServ.exe");

/* Add the Event ID message-file name to the subkey. */

if (RegSetValueEx(hk, /* subkey handle */

"EventMessageFile", /* value name */

0, /* must be zero */

REG_EXPAND_SZ, /* value type */

(LPBYTE) szBuf, /* address of value data */

strlen(szBuf) + 1)) /* length of value data*/

{

printf("could not set event message file");

return;

}

/* Set the supported types flags. */

dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |

EVENTLOG_INFORMATION_TYPE;

if (RegSetValueEx(hk, /* subkey handle */

"TypesSupported", /* value name */

0, /* must be zero */

REG_DWORD, /* value type */

(LPBYTE) &dwData, /* address of value data*/

sizeof(DWORD))) /* length of value data */

{

printf("could not set supported types");

return;

}

RegCloseKey(hk);

}