Remove croak and Perl_croak from gettext triggers. While we could
[PostgreSQL.git] / src / bin / pgevent / pgevent.c
blob32926f8720d51c9ff2826c97db35b0917c0ed900
1 /*-------------------------------------------------------------------------
3 * pgevent.c
4 * Defines the entry point for pgevent dll.
5 * The DLL defines event source for backend
8 * IDENTIFICATION
9 * $PostgreSQL$
11 *-------------------------------------------------------------------------
15 #include <windows.h>
16 #include <olectl.h>
17 #include <string.h>
19 /* Global variables */
20 HANDLE g_module = NULL; /* hModule of DLL */
22 /* Prototypes */
23 STDAPI
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
32 STDAPI
33 DllRegisterServer(void)
35 HKEY key;
36 DWORD data;
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,
58 "EventMessageFile",
60 REG_EXPAND_SZ,
61 (LPBYTE) buffer,
62 strlen(buffer) + 1))
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,
72 "TypesSupported",
74 REG_DWORD,
75 (LPBYTE) & data,
76 sizeof(DWORD)))
78 MessageBox(NULL, "Could not set the supported types.", "PostgreSQL error", MB_OK | MB_ICONSTOP);
79 return SELFREG_E_TYPELIB;
82 RegCloseKey(key);
83 return S_OK;
87 * DllUnregisterServer --- Instructs DLL to remove only those entries created through DllRegisterServer
90 STDAPI
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;
103 return S_OK;
107 * DllMain --- is an optional entry point into a DLL.
110 BOOL WINAPI
111 DllMain(HANDLE hModule,
112 DWORD ul_reason_for_call,
113 LPVOID lpReserved
116 if (ul_reason_for_call == DLL_PROCESS_ATTACH)
117 g_module = hModule;
118 return TRUE;