目前共有7篇帖子。 内容转换:不转换▼
 
点击 回复
254 6
【程序】C++调用shell32.dll中的图标选择对话框
一派护法 十九级
1楼 发表于:2016-1-14 19:59
【代码】
void CShellFuncDlg::OnButton1()
{
    // TODO: Add your control notification handler code here
    int (WINAPI *PickIconDlg)(HWND, PWSTR, UINT, int *);
    HMODULE hmdl = LoadLibrary(TEXT("shell32.dll"));
    PickIconDlg = (int (WINAPI *)(HWND, PWSTR, UINT, int *))GetProcAddress(hmdl, "PickIconDlg");

    WCHAR path[MAX_PATH] = L"C:\\windows\\system32\\shell32.dll";
    int index = 10;
    int result = PickIconDlg(NULL, path, MAX_PATH, &index);
    WCHAR str[MAX_PATH + 50];
    swprintf(str, L"You have chosen Icon %d in %s", index, path);
    MessageBoxW(m_hWnd, str, L"Icon", MB_ICONINFORMATION);

    FreeLibrary(hmdl);
}
【运行效果】
一派护法 十九级
2楼 发表于:2016-1-14 20:00
选择图标后:
一派护法 十九级
3楼 发表于:2016-1-14 20:07
一派护法 十九级
4楼 发表于:2016-1-14 20:08
Of course, shell32.dll is probably the largest icon archive in Windows.
shell32.dll可能是Windows系统中最大的图标库。。。。
http://www.cnet.com/forums/discussions/does-windows-have-other-icon-files-besides-shell32-dll-326156/
一派护法 十九级
5楼 发表于:2016-1-14 20:19
【代码2】
用户如果单击了对话框中的“取消”,则不显示消息框。
void CShellFuncDlg::OnButton1()
{
    // TODO: Add your control notification handler code here
    int (WINAPI *PickIconDlg)(HWND, PWSTR, UINT, int *);
    HMODULE hmdl = LoadLibrary(TEXT("shell32.dll"));
    PickIconDlg = (int (WINAPI *)(HWND, PWSTR, UINT, int *))GetProcAddress(hmdl, "PickIconDlg");

    WCHAR path[MAX_PATH] = L"C:\\windows\\system32\\shell32.dll";
    int index = 10;
    int result = PickIconDlg(NULL, path, MAX_PATH, &index);
    if (result == 1)
    {
        WCHAR str[MAX_PATH + 50];
        swprintf(str, L"You have chosen Icon %d in %s", index, path);
        MessageBoxW(m_hWnd, str, L"Icon", MB_ICONINFORMATION);
    }

    FreeLibrary(hmdl);
}
一派护法 十九级
6楼 发表于:2016-1-14 20:20
【链接】
MSDN上PickIconDlg函数的参考资料:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb776481%28v=vs.85%29.aspx
遗憾的是,上面写着“Deprecated API”,意思就是说这个函数已经不赞成使用了。
一派护法 十九级
7楼 发表于:2016-1-14 20:44
【链接】
Where to find most of Windows 10's native icons?
http://www.digitalcitizen.life/where-find-most-windows-10s-native-icons
这篇文章里介绍了很多Windows中的大型图标库。(很多dll的图标规模都相当于shell32.dll)

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:254 回复数:6
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2016-1-14 20:44
 
©2010-2024 Arslanbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。