1 /*-------------------------------------------------------------------------
4 * Defines the entry point for pgevent dll.
5 * The DLL defines event source for backend
11 *-------------------------------------------------------------------------
19 /* Global variables */
20 HANDLE g_module
= NULL
; /* hModule of DLL */
24 DllRegisterServer(void);
25 STDAPI
DllUnregisterServer(void);
26 BOOL WINAPI
DllMain(HANDLE hModule
, DWORD ul_reason_for_call
, LPVOID lpReserved
);
29 * DllRegisterServer --- Instructs DLL to create its registry entries
33 DllRegisterServer(void)
37 char buffer
[_MAX_PATH
];
39 /* Set the name of DLL full path name. */
40 if (!GetModuleFileName((HMODULE
) g_module
, buffer
, sizeof(buffer
)))
42 MessageBox(NULL
, "Could not retrieve DLL filename", "PostgreSQL error", MB_OK
| MB_ICONSTOP
);
43 return SELFREG_E_TYPELIB
;
47 * Add PostgreSQL source name as a subkey under the Application key in the
48 * EventLog registry key.
50 if (RegCreateKey(HKEY_LOCAL_MACHINE
, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL", &key
))
52 MessageBox(NULL
, "Could not create the registry key.", "PostgreSQL error", MB_OK
| MB_ICONSTOP
);
53 return SELFREG_E_TYPELIB
;
56 /* Add the name to the EventMessageFile subkey. */
57 if (RegSetValueEx(key
,
64 MessageBox(NULL
, "Could not set the event message file.", "PostgreSQL error", MB_OK
| MB_ICONSTOP
);
65 return SELFREG_E_TYPELIB
;
68 /* Set the supported event types in the TypesSupported subkey. */
69 data
= EVENTLOG_ERROR_TYPE
| EVENTLOG_WARNING_TYPE
| EVENTLOG_INFORMATION_TYPE
;
71 if (RegSetValueEx(key
,
78 MessageBox(NULL
, "Could not set the supported types.", "PostgreSQL error", MB_OK
| MB_ICONSTOP
);
79 return SELFREG_E_TYPELIB
;
87 * DllUnregisterServer --- Instructs DLL to remove only those entries created through DllRegisterServer
91 DllUnregisterServer(void)
94 * Remove PostgreSQL source name as a subkey under the Application key in
95 * the EventLog registry key.
98 if (RegDeleteKey(HKEY_LOCAL_MACHINE
, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL"))
100 MessageBox(NULL
, "Could not delete the registry key.", "PostgreSQL error", MB_OK
| MB_ICONSTOP
);
101 return SELFREG_E_TYPELIB
;
107 * DllMain --- is an optional entry point into a DLL.
111 DllMain(HANDLE hModule
,
112 DWORD ul_reason_for_call
,
116 if (ul_reason_for_call
== DLL_PROCESS_ATTACH
)