When I change the icon in my shortcut, why doesn’t it update on the screen?
A customer was having trouble updating the icon in one of their shortcuts. Here’s what they shared with us:
“Changing the icon from the shortcut property sheet works, but it’s not working from our code. Is the shortcut property sheet using a different API from
IShellLink::SetIconLocation? In desperation, we added
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
but that didn’t help. Did we get the flags to SHChangeNotification wrong?”
The property sheet does use the
IShellLink::SetIconLocation method to change the shortcut icon. What the customer forgot was to save their changes!
i_persist_file is the
IPersistFile that they used to load the shortcut, or they can use
QueryInterface to get a new pointer.
SHCNE_ASSOCCHANGED notification is unnecessary, and in fact it’s overkill. That’s like saying, “I want to change the color of my sofa, so I’m going to demolish my house, rebuild it, and then refurnish it with a new sofa.”
If you want to send a notification to say, “Hey, I updated this file, please go refresh any data you have cached about it,” you can do a
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, fullpath, NULL);