ElektroStudios / Easy-Link-File-Viewer

Desktop application for Windows to read, modify and write shortcut files (.lnk) with ease.
Apache License 2.0
120 stars 11 forks source link

What to do if this program can't find the icon file? #4

Open kenny1983 opened 3 years ago

kenny1983 commented 3 years ago

Hi there!

When I found your SuperUser question about this I thought my prayers had finally been answered, but alas, downloading v1.4 and trying it on a very troublesome .lnk sent me back into misery 😢.

Your program can't seem to find the icon file that is obviously embedded somewhere in the .lnk or its target (a Microsoft Word .dot template file), or elsewhere on my PC, since it clearly shows on the .lnk file itself (when placed on my desktop).

Browsing the WINWIRD.EXE application file for icons only displays the new ones since it is Word 2019 and as I'm sure you're aware, .dot files have been deprecated for a long time. But I like the style of that old classic icon, and can't find it anywhere!

I know you're just a poor indie dev like myself who doesn't have the time for these things, but I was hoping you might perhaps be able to point me in the right direction to find this pesky icon file that seems determined to hide itself from me.

If you would be so kind, I would be happy to make a donation to your PayPal account. Many thanks in advance! 😄

ElektroStudios commented 3 years ago

Hi and thanks for your comment. But you don't need to convince me with a donation, I'm here to help solve problems that could also improve this software.

However, and for what you say, it seems that it wouldn't be that easy for me to replicate your scenario in order to reproduce the problem that you describe and fix it. Just because I have stopped myself from using Microsoft Office products like a decade ago, and my machine on Windows 10 doesn't have registered any default old or newer icon for .dot file type.

Also, the docs for Shell Links and also for IShellLink::GetIconLocation function doesn't addreesses any issue regarding your problem that I could investigate and give you a proper solution.

Note that file icons can be dynamically generated by icon handlers and might not expose the path to its images. The current code of my program will use the native IShellLinkW interface to retrieve the path of the file that contains the icon representing the shortcut file, but this will be retrieved only in case that the icon path is stored in the shortcut file structure. So, when the program shows empty the icon path field, it is because there is no icon path information "embedded" in the shortcut file.

According to some research, there would be at least three possible known ways to get the icon path for a file. One of them is using the native SHGetFileInfo function, another is using the IShellLinkW::GetIconLocation interface's function, and the last is using IExtractIcon::GetIconLocation interface's function, however, from what I read, both the first and second functions are calling IExtractIcon::GetIconLocation on the background, so at the end the three approaches will give a empty icon path for a file, or at least that is the result I got when testing them. For getting the icon path for folders they work, but not for files, at least for me.

I will still investigate a little bit more, and asking on StackOverflow to bring us a solution for this.

Anyways, if the problem is that you can't find where is the file in your system containing the icon that you want, then you could try to analyze the (progids for .dot) registry key mentioned in the accepted answer of this thread to track for the icon file location that you are searching. You also could try to track the icon location with FileTypesMan and maybe ShellMenuView programs from Nirsoft.

By the way, I finally installed Microsoft Word 2019 for trying to understand your problem, but my program detects fine the icon image (not the icon path, because it is not specified) for a .lnk file that points to a .dot file.

Cheers!. And feel free to continue this conversation if you still need help.

kenny1983 commented 3 years ago

Wow what a well-written and comprehensive answer, thank you! I really appreciate your time taken looking into this, but as you said, it will benefit us both if you find a solution.

I will look into the documentation and other links that you provided and see if I can also make sense of this business.

Cheers mate! 😄

kenny1983 commented 3 years ago

I just happened to be looking through the Office install directory on my PC and stumbled across this file: C:\Program Files\Microsoft Office\root\Office16\WORDICON.EXE. Can't believe I didn't notice it sooner! It indeed contains the icons I was looking for, so my original problem is now solved 🎉😄!

Don't know if that will help you narrow down the issue with your program though, but I thought I'd let you know just in case. If/when I get some spare time I may come back here and re-join the effort.

Keep me updated of any developments though, and good luck 👍!