Use correct icon index in SIC_OverlayShortcutImage() to properly load
shortcut overlay icon from registry instead of always using default icon.
This allows to use custom shortcut icon set by user, in case it was
specified there.
As FIXME comment stated, the icon indexes were not implemented in the far
past, so this workaround was badly required. But now they are implemented,
so no need to always use default resource from shell32, enable the correct
code instead.
Also adapt this to CShellLink::CreateShortcutIcon() when the shortcut icon
is being changed in its properties dialog, as well as in CNewMenu class
when displaying menu items for creating a new folder or a shortcut.
Addendum to f9a5344254. CORE-14758
Implement proper reading the current user's icons from registry.
CORE-14758
- Load the icons specified by user in registry in the following keys:
"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\DefaultIcon"
(virtual namespace folders)
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons"
(filesystem folders and drives)
- Implement two functions HCU/HLM_GetIconW for reading the icons
from mentioned HKCU and HKLM keys accordingly.
- Use HCR_RegGetIconW for falling back to default icons.
This function always loads only default icons, even when
the custom ones are specified by user.
- Refactor SIC_LoadOverlayIcon to use newly implemented HLM_GetIconW.
These changes apply to:
- virtual namespace folders and other desktop items (like My Computer,
My Documents, Network Places, Recycle Bin, Web Browser (aka Internet
Explorer), Control Panel and some of its items);
- normal filesystem directories;
- all types of drives (fixed disk drives, removable drives, CD-ROMs,
RamDisks and network drives). Handle invalid drives, setting blank
icon for them, since they cannot be recognized or mounted correctly.
Also, load the autorun icons first to avoid overriding them by the
icons defined in registry.
I've rechecked twice: excluding Start Menu icons, Desktop Workspace icon
and some FS folder icons that have their own desktop.ini configuration
files (we probably should write the custom icons we load to these configs,
as Windows does it, perhaps with WritePrivateProfileStringW), all other
icons can be changed now (only ones that can be changed on XP SP3 / 2003
SP2) via built-in system tools (like Desktop icons in desk.cpl) or any
3rd-party tools without modifying system resources.
Also all icons for the known file types can be changed,
same as before my changes.
Regarding Start Menu icons:
- changing them should be correctly implemented in explorer
instead of shell32, as the former is responsible for the Start Menu
and partially for the taskbar;
- in order to actually use all of them, we need to implement modern
Start Menu first.
Useful reference: http://www.winfaq.de/faq_html/Content/tip0000/onlinefaq.php?h=tip0162.htm
ExtractIconEx() returns the number of successfully extracted icons from a file. The routine may return 0 in case no icons could be extracted but it could also return 0 if the file is not a valid PE image file or the file couldn't be found.
PrivateExtractIcons and the internal USER32 routine, ICO_ExtractIconExW(), return -1 in such scenarios. The behaviour is correct however we do not want that ExtractIconEx() returns -1 as well as it doesn't comply with the general documentation. In such cases, simply return 0 as no successful icons have been extracted due to related file failures.
CORE-16535