Note that there are some explanatory texts on larger screens.

plurals
  1. POSHGetFileInfo on the public desktop
    primarykey
    data
    text
    <p>I'm having an issue with using SHGetFileInfo on the public desktop and files in the public desktop. I'll focus on the actual desktop folder (CSIDL_COMMON_DESKTOPDIRECTORY or usually "C:\Users\Public\Desktop"). Also - I've started seeing this behavior only recently, but I can't pinpoint the exact change which made it faulty. The actual call to ShGetFileInfo has not changed (as far as I can tell).</p> <p>So I have this (I've omitted intermediate error checks to shorten - the function calls return with success):</p> <pre><code>SHFILEINFOW info; uint32_t return_value = 0; uint32_t flags = SHGFI_TYPENAME|SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX; uint32_t attributes = FILE_ATTRIBUTE_NORMAL; wchar_t *path = L"C:\\Users\\Public\\Desktop"; return_value = SHGetFileInfoW(path, attributes, &amp;info, sizeof(SHFILEINFOW), flags); printf("[%ls] %u ", path, return_value); </code></pre> <p>This returns 0 as the return value. If I populate path using:</p> <pre><code>SHGetFolderPathW(NULL, CSIDL_COMMON_DESKTOPDIRECTORY, NULL, 0, path) </code></pre> <p>I get the same result. But if I use the pidl, as in:</p> <pre><code>LPITEMIDLIST pidl = NULL; SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_DESKTOPDIRECTORY, &amp;pidl); return_value = SHGetFileInfoW((LPCWSTR) pidl, attributes, &amp;info, sizeof(SHFILEINFOW), flags | SHGFI_PIDL); </code></pre> <p>Then I get something which I expect, a handle to the system small icon list.</p> <p>I can't tell what I'm doing wrong - and it only happens on this specific folder. I actually need icons for the items inside the directory, so using the pidl doesn't seem to be an option right now. Any ideas on what is the expected way to retrieve icons from the common desktop?</p> <p>--</p> <p>I should mention this behavior happens on Windows Vista - using the path populated by SHGetFolderPathW on XP works fine</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload