gpt4 book ai didi

c++ - InitCommonControlsEx() 在 Windows 8.1 中因 ICC_LINK_CLASS 而失败

转载 作者:行者123 更新时间:2023-11-28 02:19:25 25 4
gpt4 key购买 nike

我正在尝试在我的窗口上放置一个简单的超链接。

INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccx.dwICC = ICC_LINK_CLASS; // CommCtrl.h: #define ICC_LINK_CLASS 0x00008000
bool bResult = InitCommonControlsEx(&iccx); // bResult is false.
DWORD dwError = GetLastError(); // dwError is 0.

hWnd = CreateWindowExW( /*_In_ DWORD*/ 0,
/*_In_opt_ LPCTSTR*/ WC_LINK, // CommCtrl.h: #define WC_LINK L"SysLink"
/*_In_opt_ LPCTSTR*/ L"Hello World",
/*_In_ DWORD*/ WS_VISIBLE | WS_CHILD | WS_TABSTOP,
/*_In_ int*/ 50,
/*_In_ int*/ 200,
/*_In_ int*/ 100,
/*_In_ int*/ 20,
/*_In_opt_ HWND*/ hWndParent,
/*_In_opt_ HMENU*/ NULL,
/*_In_opt_ HINSTANCE*/ hInstance,
/*_In_opt_ LPVOID*/ NULL);
DWORD dwError = GetLastError(); // hWnd is NULL and dwError is 1407.

错误代码 1407 在 here 中进行了解释如下。

ERROR_CANNOT_FIND_WND_CLASS
1407 (0x57F)
Cannot find window class.

我使用的是 Windows 8.1 Pro x64,我从未在任何其他版本的 Windows 上尝试过此代码。

这里有什么问题?

最佳答案

如你所想,添加

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

是解决问题的一种方法。

SysLink 控件仅在 Common Controls 版本 6 中添加。backwards compatibility reasons , Common Controls 6 默认情况下未启用。您必须通过创建 list 来选择加入它。

list 可以作为单独的文件(名为 program.exe.manifest)或作为具有特定资源 ID 的资源存在。 #pragma 行告诉 Microsoft 的链接器为您生成第二个。您也可以自己制作任何一种表格。 Here's how.

关于c++ - InitCommonControlsEx() 在 Windows 8.1 中因 ICC_LINK_CLASS 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33060724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com