You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2007/02/28 22:29:36 UTC
svn commit: r512980 -
/logging/log4j/branches/v1_2-branch/src/java/org/apache/log4j/nt/nteventlog.cpp
Author: carnold
Date: Wed Feb 28 13:29:35 2007
New Revision: 512980
URL: http://svn.apache.org/viewvc?view=rev&rev=512980
Log:
Bug 41169: Add DllRegisterServer and DllUnregisterServer entry points
Modified:
logging/log4j/branches/v1_2-branch/src/java/org/apache/log4j/nt/nteventlog.cpp
Modified: logging/log4j/branches/v1_2-branch/src/java/org/apache/log4j/nt/nteventlog.cpp
URL: http://svn.apache.org/viewvc/logging/log4j/branches/v1_2-branch/src/java/org/apache/log4j/nt/nteventlog.cpp?view=diff&rev=512980&r1=512979&r2=512980
==============================================================================
--- logging/log4j/branches/v1_2-branch/src/java/org/apache/log4j/nt/nteventlog.cpp (original)
+++ logging/log4j/branches/v1_2-branch/src/java/org/apache/log4j/nt/nteventlog.cpp Wed Feb 28 13:29:35 2007
@@ -200,4 +200,60 @@
}
+//
+// Entry point which registers default event source (Log4j)
+// when invoked using regsvr32 tool.
+//
+//
+STDAPI __declspec(dllexport) DllRegisterServer(void) {
+ HRESULT hr = E_FAIL;
+ HMODULE hmodule = GetModuleHandleW(L"NTEventLogAppender.dll");
+ if (hmodule != NULL) {
+ wchar_t modpath[_MAX_PATH];
+ DWORD modlen = GetModuleFileNameW(hmodule, modpath, _MAX_PATH - 1);
+ if (modlen > 0) {
+ modpath[modlen] = 0;
+ const wchar_t key[] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Log4j";
+ DWORD disposition;
+ HKEY hkey = 0;
+
+ LONG stat = RegCreateKeyExW(HKEY_LOCAL_MACHINE, key, 0, NULL,
+ REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
+ &hkey, &disposition);
+ if (stat == ERROR_SUCCESS) {
+ stat = RegSetValueExW(hkey, L"EventMessageFile", 0, REG_EXPAND_SZ,
+ (LPBYTE) modpath, (wcslen(modpath) + 1) * sizeof(wchar_t));
+ if(stat == ERROR_SUCCESS) {
+ stat = RegSetValueExW(hkey, L"CategoryMessageFile", 0, REG_EXPAND_SZ,
+ (LPBYTE) modpath, (wcslen(modpath) + 1) * sizeof(wchar_t));
+ }
+ if(stat == ERROR_SUCCESS) {
+ DWORD value = 7;
+ stat == RegSetValueExW(hkey, L"TypesSupported", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
+ }
+ if(stat == ERROR_SUCCESS) {
+ DWORD value = 6;
+ stat == RegSetValueExW(hkey, L"CategoryCount", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
+ }
+ LONG closeStat = RegCloseKey(hkey);
+ if (stat == ERROR_SUCCESS && closeStat == ERROR_SUCCESS) {
+ hr = S_OK;
+ }
+ }
+ }
+ }
+ return hr;
+}
+
+
+//
+// Entry point which unregisters default event source (Log4j)
+// when invoked using regsvr32 tool with /u option.
+//
+//
+STDAPI __declspec(dllexport) DllUnregisterServer(void) {
+ LONG stat = RegDeleteKeyW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Log4j");
+ return (stat == ERROR_SUCCESS || stat == ERROR_FILE_NOT_FOUND) ? S_OK : E_FAIL;
+}
#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org