66{
69 char buffer[_MAX_PATH];
70 char key_name[400];
71
72 /* Set the name of DLL full path name. */
73 if (!GetModuleFileName((HMODULE)
g_module, buffer,
sizeof(buffer)))
74 {
75 MessageBox(NULL, "Could not retrieve DLL filename", "PostgreSQL error", MB_OK | MB_ICONSTOP);
76 return SELFREG_E_TYPELIB;
77 }
78
79 /*
80 * Add PostgreSQL source name as a subkey under the Application key in the
81 * EventLog registry key.
82 */
83 _snprintf(key_name, sizeof(key_name),
84 "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",
86 if (RegCreateKey(HKEY_LOCAL_MACHINE, key_name, &
key))
87 {
88 MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
89 return SELFREG_E_TYPELIB;
90 }
91
92 /* Add the name to the EventMessageFile subkey. */
93 if (RegSetValueEx(
key,
94 "EventMessageFile",
95 0,
96 REG_EXPAND_SZ,
97 (LPBYTE) buffer,
98 strlen(buffer) + 1))
99 {
100 MessageBox(NULL, "Could not set the event message file.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
101 return SELFREG_E_TYPELIB;
102 }
103
104 /* Set the supported event types in the TypesSupported subkey. */
105 data = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
106
107 if (RegSetValueEx(
key,
108 "TypesSupported",
109 0,
110 REG_DWORD,
112 sizeof(DWORD)))
113 {
114 MessageBox(NULL, "Could not set the supported types.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
115 return SELFREG_E_TYPELIB;
116 }
117
119 return S_OK;
120}