Wrong EXE icon if file is in "%temp%" folder

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Wrong EXE icon if file is in "%temp%" folder

Post by *MVV »

No, I don't mean temporary folder but folder with name %TEMP%. Maybe here it is a Windows bug since Windows doesn't show such icons also.
I just want to know if we can do something with it or not.
User avatar
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi, MVV.

This works with the variables %PROGRAMFILES%, %USERPROFILE% and %APPDATA% e.g. as well if you use them as folder names. Explorer and T.C. will display the plain executable file icon only and not extract the icon from the executable file.

This behaviour can be reproduced by using T.C. 7.50a or T.C. 7.04a as well. (and Explorer of course)

Kind regards,
Karl
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

As I understand, TC extracts icons manually. So I'm interesting can this be solved or Windows doesn't allow to extract icons for files in such folders at all (it seems to be strange 'cause API functions usually can't handle envoronment variables).
User avatar
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi, MVV.

Let me speculate wildly, hm, maybe not so wildly after all: API functions cannot handle environment variables. OK, you will know better than I do. But programmers can.
Isn't it imaginable that the Microsoft developers and some well-know Swiss developer are using the same approach? They see an environment variable and call the appropriate function in order to expand it. But too bad in our cases, beause some :wink: dumbo :wink: has created foldernames looking like environment variables which need expanding.
As a result they are trying to extract a programme icon from a location which does not exist. The fallback method is to display the standard executable file icon instead.
I am curious to learn how far away my speculation really is from the truth ...

Kind regards,
Karl
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

karlchen wrote:I am curious to learn how far away my speculation really is from the truth ...
It is truth :D to confirm
1. Create dir like C:\%temp% and put text file inside it e.g. Keyboard.txt.
2. Run Notepad or any other program and PASTE C:\%temp%\Keyboard.txt in the file name field then press open
3. "The file name is not valid." is popup.

I think this is because when you paste or type the file name, the dialog calls ExpandEnvironmentStrings to get the file, and as a result ExpandEnvironmentStrings return invalid path, something like C:\C:\Windows\Temp\Keyboard.txt

It seems that SHGetFileInfo calls ExpandEnvironmentStrings too.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I know that in most cases software calls expanding envvars functions. But AFAIK to extract icon from file we need to call function like ExtractIconEx that doesn't expand envvars.

BTW, as I see, SHGetFileInfo function tries to expand envvars in passed name. :!:
ts4242 wrote:It seems that SHGetFileInfo calls ExpandEnvironmentStrings too.
I noticed that too using debugger. :)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, this isn't supported. I don't have any plans to change it because it will break handling of environment variables in many other places, e.g. when the user gives the location if an icon in the button bar with an env. var in the name, or when an association contains env. vars.
Author of Total Commander
https://www.ghisler.com
Post Reply