English 中文(简体)
Load the Default Icon For the Shell
原标题:

The default icon in Vista is listed under:

HKEY_CLASSES_ROOT Unknown DefaultIcon

As:

%SystemRoot%System32shell32.dll,0

I want to load a 48x48 version of that Icon in C++. I have tried:

hIcon = (HICON)::LoadImage(hmShell32, MAKEINTRESOURCE(0), IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR);

However I get back a NULL hIcon and when I call ::GetLastError() it returns: ERROR_RESOURCE_TYPE_NOT_FOUND

How do I load the default icon out of Shell32.dll?

Thanks in advance, Wayne Walter Berry

{6230289B-5BEE-409e-932A-2F01FA407A92}

最佳回答

If you only have to support Vista/7 then this should work.

SHSTOCKICONINFO iconInfo;
iconInfo.cbSize = sizeof(iconInfo);
if(SUCCEEDED(SHGetStockIconInfo(SIID_DOCNOASSOC, SHGSI_ICONLOCATION, &iconInfo)))
{       
    wcex.hIcon = (HICON)::LoadImage(LoadLibrary(iconInfo.szPath), MAKEINTRESOURCE(-iconInfo.iIcon), IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR);
}
问题回答

暂无回答




相关问题
how to reliable capture display setting changed

static void Main() { // Set the SystemEvents class to receive event notification when a user // when display settings change. SystemEvents.DisplaySettingsChanged += new ...

Why use CComBSTR instead of just passing a WCHAR*?

I m new to COM. What exactly is the advantage of replacing: L"String" with CComBSTR(L"String") I can see a changelist in the COM part of my .NET application where all strings are replaced in this ...

COM Basic links

folks can you provide me the tutorial link or .pdf for learning basic COM?. i do google it.. still i recommend answers of stackoverflow so please pass me.. Thanks

Statically linking Winsock?

I m using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I m looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I ...

热门标签