- // FIXME: http://stackoverflow.com/questions/2976489/ishelllinkseticonlocation-translates-my-icon-path-into-program-files-which-i
- // if (PathFullyUnExpandEnvStringsW(pszIconPath, szUnExpIconPath, _countof(szUnExpIconPath)))
- bSuccess = PathUnExpandEnvStringsW(pszIconPath, szUnExpIconPath, _countof(szUnExpIconPath));
- if (bSuccess && wcscmp(pszIconPath, szUnExpIconPath) != 0)
+#ifdef ICON_LINK_WINDOWS_COMPAT
+ /* Try to fully unexpand the icon path */
+ // if (PathFullyUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath)))
+ BOOL bSuccess = PathUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath));
+ if (bSuccess && wcscmp(pszIconPath, szIconPath) != 0)
+#else
+ /*
+ * In some situations, described in http://stackoverflow.com/questions/2976489/ishelllinkseticonlocation-translates-my-icon-path-into-program-files-which-i
+ * the result of PathUnExpandEnvStringsW() could be wrong, and instead
+ * one would have to store the actual provided icon location path, while
+ * creating an icon environment block ONLY if that path already contains
+ * environment variables. This is what the present case is trying to implement.
+ */
+ SHExpandEnvironmentStringsW(pszIconPath, szIconPath, _countof(szIconPath));
+ if (wcscmp(pszIconPath, szIconPath) != 0)
+#endif