fixed SF# 1995073: setupRegistry is broken if POCO_WIN32_UTF8 enabled

This commit is contained in:
Guenter Obiltschnig 2008-09-16 20:48:33 +00:00
parent 721e4429ad
commit 0880710370

View File

@ -1,7 +1,7 @@
// //
// EventLogChannel.cpp // EventLogChannel.cpp
// //
// $Id: //poco/svn/Foundation/src/EventLogChannel.cpp#2 $ // $Id: //poco/1.3/Foundation/src/EventLogChannel.cpp#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging
@ -236,38 +236,28 @@ void EventLogChannel::setUpRegistry() const
{ {
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring path; std::wstring path;
std::wstring libName = L"PocoMsg.dll";
path = findLibrary(libName.c_str());
if (path.empty())
{
#if defined(POCO_DLL) #if defined(POCO_DLL)
#if defined(_DEBUG) #if defined(_DEBUG)
libName = L"PocoFoundationd.dll"; path = findLibrary(L"PocoFoundationd.dll");
path = findLibrary(libName.c_str());
#else #else
libName = L"PocoFoundation.dll"; path = findLibrary(L"PocoFoundation.dll");
path = findLibrary(libName.c_str());
#endif #endif
#endif #endif
}
if (path.empty())
path = findLibrary(L"PocoMsg.dll");
#else #else
std::string path; std::string path;
std::string libName = "PocoMsg.dll";
path = findLibrary(libName.c_str());
if (path.empty())
{
#if defined(POCO_DLL) #if defined(POCO_DLL)
#if defined(_DEBUG) #if defined(_DEBUG)
libName = "PocoFoundationd.dll"; path = findLibrary("PocoFoundationd.dll");
path = findLibrary(libName.c_str());
#else #else
libName = "PocoFoundation.dll"; path = findLibrary("PocoFoundation.dll");
path = findLibrary(libName.c_str());
#endif #endif
#endif #endif
}
if (path.empty())
path = findLibrary("PocoMsg.dll");
#endif #endif
if (!path.empty()) if (!path.empty())
@ -275,8 +265,8 @@ void EventLogChannel::setUpRegistry() const
DWORD count = 8; DWORD count = 8;
DWORD types = 7; DWORD types = 7;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1); RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) sizeof(wchar_t)*(path.size() + 1));
RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1); RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) sizeof(wchar_t)*(path.size() + 1));
RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count)); RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count));
RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types)); RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types));
#else #else
@ -284,16 +274,6 @@ void EventLogChannel::setUpRegistry() const
RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1); RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1);
RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count)); RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count));
RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types)); RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types));
#endif
}
else
{
std::string uLibName;
#if defined(POCO_WIN32_UTF8)
UnicodeConverter::toUTF8(libName, uLibName);
throw NotFoundException(uLibName);
#else
throw NotFoundException(libName);
#endif #endif
} }
} }