Is there a way for a Windows program to find out what shortcut (i.e. .lnk file), if any, it was invoked from, so that it can pick up the shortcut's icon?
You can call GetStartupInfo()
to fill a STARTUPINFO
structure. If the STARTF_TITLEISLINKNAME
flag is set, the STARTUPINFO::lpTitle
field contains the path to the .lnk
file.
(This was undocumented for a long time. It probably works all the way back to Win95.)