GetImmersiveColorTypeFromName始终返回-1

时间:2015-11-12 20:05:45

标签: c++ c winapi

尝试调用GetImmersiveColorTypeFromName以获取Windows 10通知区域的颜色。 但它总是返回-1

    typedef int(WINAPI*pGetImmersiveColorTypeFromName)(char* name);
    const pGetImmersiveColorTypeFromName GetImmersiveColorTypeFromName = (pGetImmersiveColorTypeFromName)GetProcAddress(hModule, (LPCSTR)96);
    if (GetImmersiveColorTypeFromName)
    {
        colorType = GetImmersiveColorTypeFromName("ImmersiveApplicationTextDarkTheme");
    }

我已经尝试了很多其他名字,但总是得到-1

1 个答案:

答案 0 :(得分:3)

GetImmersiveColorTypeFromName需要一个宽字符串,因此请将声明从char*更改为wchar_t*

typedef int(WINAPI*pGetImmersiveColorTypeFromName)(wchar_t* name);
const pGetImmersiveColorTypeFromName GetImmersiveColorTypeFromName = (pGetImmersiveColorTypeFromName)GetProcAddress(hModule, (LPCSTR)96);
if (GetImmersiveColorTypeFromName)
{
    colorType = GetImmersiveColorTypeFromName(L"ImmersiveApplicationTextDarkTheme");
}