Skip to content

Poco::EventLogChannel fails to find 64bit Poco Foundation dll #259

@ghost

Description

In EventLogChannel::setUpRegistry(), the code tries to find PocoFoundation.dll (or PocoFoundationd.dll) and add the path to registry key. But in 64bit environment, the dll is named "PocoFoundation64.dll/PocoFoundation64d.dll", and the code fails to find the library because name doesn't match.

void EventLogChannel::setUpRegistry() const
{
    std::string key = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
    key.append(_logFile);
    key.append("\\");
    key.append(_name);
    HKEY hKey;
    DWORD disp;
#if defined(POCO_WIN32_UTF8)
    std::wstring ukey;
    UnicodeConverter::toUTF16(key, ukey);
    DWORD rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ukey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
#else
    DWORD rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, key.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
#endif
    if (rc != ERROR_SUCCESS) return;

    if (disp == REG_CREATED_NEW_KEY)
    {

#if defined(POCO_WIN32_UTF8)
        std::wstring path;
        #if defined(POCO_DLL)
            #if defined(_DEBUG)
                path = findLibrary(L"PocoFoundationd.dll");
            #else
                path = findLibrary(L"PocoFoundation.dll");
            #endif
        #endif

        if (path.empty())
            path = findLibrary(L"PocoMsg.dll");
#else
        std::string path;
        #if defined(POCO_DLL)
            #if defined(_DEBUG)
                path = findLibrary("PocoFoundationd.dll");
            #else
                path = findLibrary("PocoFoundation.dll");
            #endif
        #endif

        if (path.empty())
            path = findLibrary("PocoMsg.dll");
#endif

        if (!path.empty())
        {
                   ...

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions