Hello magnus, > I assume you mean src/bin/pgevent, to be consistent with the naming used > inside the program.
OK, I Modify Makefile subdir value. In fact I name it pg_event because many directory under src/bin began with pg_ . > Second, I'd register the source as "PostgreSQL", not "PostGreSQL". I > don't think the "captital-G" is generally used, and it's specifically > NOT what the backend uses. Sure, the key reading process is > case-insensitive today, but it's still a good idea to keep things > consistent :-) I modify pgevent.c, for your both remarks: "capital G" are disappears from source and I move GetModuleFilename() before RegCreateKey() call. I sent full set file again, it will be easier to apply. regards, Laurent
LANGUAGE 0x9,0x1 1 11 MSG00001.bin
Makefile
Description: Binary data
MSG00001.bin
Description: Binary data
/*------------------------------------------------------------------------- * * pgevent.c * Defines the entry point for pgevent dll. * The DLL defines event source for backend * * * IDENTIFICATION * $PostgreSQL$ * *------------------------------------------------------------------------- */ #include "windows.h" #include "olectl.h" #include "string.h" /* Global variables */ HANDLE g_hModule = NULL; /* hModule of DLL */ /* Prototypes */ STDAPI DllRegisterServer(void) ; STDAPI DllUnregisterServer(void); BOOL WINAPI DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ); /* * DllRegisterServer --- Instructs DLL to create its registry entries */ STDAPI DllRegisterServer(void) { HKEY hk; DWORD dwData; char szBuffer[_MAX_PATH]; /* Set the name of DLL full path name. */ if (!GetModuleFileName((HMODULE)g_hModule, szBuffer, sizeof(szBuffer))) { MessageBox(NULL, "Could not retrieve DLL filename", "PostgreSQL error", MB_OK|MB_ICONSTOP); return SELFREG_E_TYPELIB; } /* Add PostgreSQL source name as a subkey under the Application key in the EventLog registry key. */ if ( RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL", &hk) ) { MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP); return SELFREG_E_TYPELIB; } /* Add the name to the EventMessageFile subkey. */ if (RegSetValueEx(hk, "EventMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) szBuffer, strlen(szBuffer) + 1)) { MessageBox(NULL, "Could not set the event message file.", "PostgreSQL error", MB_OK|MB_ICONSTOP); return SELFREG_E_TYPELIB; } /* Set the supported event types in the TypesSupported subkey. */ dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; if (RegSetValueEx(hk, "TypesSupported", 0, REG_DWORD, (LPBYTE) &dwData, sizeof(DWORD))) { MessageBox(NULL, "Could not set the supported types.", "PostgreSQL error", MB_OK|MB_ICONSTOP); return SELFREG_E_TYPELIB; } RegCloseKey(hk); return S_OK; } /* * DllUnregisterServer --- Instructs DLL to remove only those entries created through DllRegisterServer */ STDAPI DllUnregisterServer(void) { /* Remove PostgreSQL source name as a subkey under the Application key in the EventLog registry key. */ if ( RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL") ) { MessageBox(NULL, "Could not delete the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP); return SELFREG_E_TYPELIB; } return S_OK; } /* * DllMain --- is an optional entry point into a DLL. */ BOOL WINAPI DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { if ( ul_reason_for_call == DLL_PROCESS_ATTACH ) { g_hModule = hModule; } return TRUE; }
; dlltool --output-def pgevent.def pgevent.o pgmsgevent.o EXPORTS [EMAIL PROTECTED] @ 1; [EMAIL PROTECTED] @ 2;
// // Values are 32 bit values layed out as follows: // // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // +---+-+-+-----------------------+-------------------------------+ // |Sev|C|R| Facility | Code | // +---+-+-+-----------------------+-------------------------------+ // // where // // Sev - is the severity code // // 00 - Success // 01 - Informational // 10 - Warning // 11 - Error // // C - is the Customer code flag // // R - is a reserved bit // // Facility - is the facility code // // Code - is the facility's status code // // // Define the facility codes // // // Define the severity codes // // // MessageId: PGWIN32_EVENTLOG_MSG // // MessageText: // // %1. // #define PGWIN32_EVENTLOG_MSG 0x00000000L
pgmsgevent.mc
Description: Binary data
---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings