Custom/Portable File Icons and .ico extension

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
autocart
Posts: 758
Joined: 26 Sep 2013 15:22

Custom/Portable File Icons and .ico extension

Post by autocart » 03 Jun 2019 18:28

Hi all,

Does anyone know of a way in XY to specify each .ico file as file icon for itself?
Kind of like:
*.ico><the file in question itself>

In Windows that is normally the standard using "%1" as icon recource, as far as I saw, but of course it can happen that a user defined program for opening and thus a different icon is set in the registry.

Regards, S.
customInlineRenameKeys ("OldStyle", "Mouse++" and "Ultimate"), clipboardHelper_and_XYEscToList

aminomancer
Posts: 14
Joined: 26 May 2019 06:29

Re: Custom/Portable File Icons and .ico extension

Post by aminomancer » 09 Jul 2019 05:53

you would have to define a new rule for each file but if you want to do that, instead of typing *.ico>blahblah.ico, do blahblah.ico>blahblah.ico
i'm not sure why you'd do that though, unless you intentionally created a general file icon rule for *.ico, or i guess accidentally installed some software that changed your shell icon handler for .ico. if that is the case and you just want to fix it, download "Default Programs Editor" since it will simplify the process. open it, click create or restore a backup of registry settings, and go through with backing up your registry in case we break something. then go back to the main menu, click file type settings > icon > search ".ico" (you may have to backspace and type it again a couple times, the search thing is a little buggy). when you get it click Next, then at the bottom click Use the file's own path for the icon. you probably at least need to restart explorer. you may need to delete the icon cache and log out and in. might as well just reboot your computer though.
if that doesn't fix it, go back to the backup settings and restore your earlier backup. go to the registry editor and look for .ico under HKEY_CLASSES_ROOT\.ico, HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.ico, and HKEY_CURRENT_USER\Software\Classes\.ico
none of these keys should have a DefaultIcon subkey. HKLM's key should only have a persistenthandler subkey. current user's key could have any number of subkeys but if it has a defaulticon subkey, get rid of it. HKCR's key should have a persistenthandler subkey and, i think, openwithprogids. again if it has a defaulticon subkey remove it.
if there's not a defaulticon subkey or iconhandler subkey or any other unknown subkey with icon in the name, in any of these, then i would guess the extension .ico has been mapped to a different filetype. like 7-zip remaps .zip from its default filetype class to one called 7-zip .zip or something like that. it's pretty common but irritating. you won't be able to guess it probably so look up FileTypesMan.exe and download that. open it and organize by extension column. find .ico and you want the rest of the columns like this. Type name: icofile. Description: Icon. MIME Type: image/x-icon. Perceived Type: image. You probably don't need to change the last 2, you will have noticed those properly set in the previous step of checking the registry keys. But most importantly just check the Default Icon column where it should say %1.

By the way, there is a program called fixwin which is supposed to be able to fix icons. I just haven't seen much documentation on how it does what it does so I never wanted to take a risk with using it. But it might be able to fix file icons in one click so idk.

From your description it's kind of hard to tell what exactly you're experiencing. I can't tell if you're not seeing ico thumbnails in xyplorer or in windows' explorer as well. If you're not seeing ico thumbnails in details view mode in either file explorer or xyplorer then it's definitely a registry problem. If you're seeing the mini-thumbnails as icons, in details view, in file explorer, then it's definitely not a registry problem and definitely a problem with your xyplorer settings. You need to have thumbnails turned on I think. And of course you need to not have a wildcard rule for ico files in general, since that will override the dynamic icon handler with a plain old static icon. Unfortunately I run into that problem with executables and shortcuts (.lnk) a lot. Most serious executables have a built-in file icon which looks nice. But if you ever compile your own software sometimes you don't give it a file icon. So I'm used to seeing windows' default exe icon and it bothers me, since I have totally different default icons for every other file type in xyplorer. But if I set a portable file icon for *.exe it will override all the built-in icons for every .exe file. So then all my software looks the same. It sucks because the same applies to shortcuts. If you give a shortcut a custom icon through the properties menu, but the exe it targets has no built-in icon, it will default to whatever portable icon you had set for .lnk files. Which is pretty weird because it's the exact opposite behavior of what you have for exe files. If xyplorer can give .lnk files a default icon but prefer their user-defined custom shell icons, if available, then why can't it do the same with exes' built in icons? And if it can show the lnk's custom icon for an exe with a built-in icon, why can't it show the same custom icon for an exe with no built-in icon? Pretty weird inconsistency if you ask me, haha. So in general you should really avoid defining portable icons for any file type which has a dynamic icon handler. Keep in mind that's different from thumbnail handler. Images have thumbnail handlers but static icons. Ico files have icon handlers so if you define a portable icon for the filetype you will have to define custom portable icons for ALL individual ico files. Which would be an absolute nightmare, that is what icon handlers are for after all. I really hope this weakness is patched eventually, for ico files it may not matter but it does really matter with executables. msi files have SUCH an ugly default icon in windows, but if you give msi a portable icon in xyplorer you cover up the pretty icon for all the msi files which DO have a built-in icon resource.

autocart
Posts: 758
Joined: 26 Sep 2013 15:22

Re: Custom/Portable File Icons and .ico extension

Post by autocart » 11 Jul 2019 11:33

I did not read that whole pile of letters, but did u see the title of this thread?:
Custom/Portable File Icons and .ico extension

This is a feature in XY: Tools -> List Management -> Portable File Icons
customInlineRenameKeys ("OldStyle", "Mouse++" and "Ultimate"), clipboardHelper_and_XYEscToList

aminomancer
Posts: 14
Joined: 26 May 2019 06:29

Re: Custom/Portable File Icons and .ico extension

Post by aminomancer » 11 Jul 2019 16:19

autocart wrote:
11 Jul 2019 11:33
I did not read that whole pile of letters, but did u see the title of this thread?:
Custom/Portable File Icons and .ico extension

This is a feature in XY: Tools -> List Management -> Portable File Icons
Image

Uh, yeah, that's what I'm talking about lol. Kinda rude considering how much time I spent trying to help you solve your problem. If you're not going to read what I wrote then why are you even responding to it in the first place. Anyway I'm saying portable file icons works just fine for ico files. What you're asking for is the default behavior of xyplorer. You're not supposed to set any rules for ico files, they already use %1 as the icon resource by default. Just look at the image I posted, that is the default behavior... isn't that obvious? It works exactly the same way file explorer does. %1 is not exactly a path, it's a selector. You can't use %1 as an icon resource in shell if the file itself requires an icon handler to interpret it. That's what icon handlers are for. There isn't any way to define a custom rule without removing the icon handler. But fortunately for .ico files there isn't any reason to. Unless you're working on some really obscure script which needs to only display .ico files with their icon resource programmatically, and use a static icon at other times, there's no point, since all ico files have an icon resource. Unlike executables, which only contain icon resources optionally, ico files are exclusively icon resources. Anything you do to add rules on top of the default icon handler is going to overwrite the icon handler with a simple default icon. That's probably why nobody else replied to your thread, it's confusing because you're asking for something which you'd have to go out of your way to not already get by default. You were really vague in your post but if I understood correctly, what you're experiencing is either 1) a consequence of the fact that xyplorer can't distinguish between icon handlers and icons, and can only show thumbnails for images with portable file icons also defined because windows generates image thumbnails via thumbnail handlers, not icon handlers. When you look at an .ico file it shows you a thumbnail preview of the icon even in 'details view,' like 16x16. That is not the case for images, it uses the default file icon for 16x16 and uses the thumbnail handler for the larger preview sizes. So .ico isn't a special case of an image thumbnail, it's a completely different situation. The file icon is not defined by an image resource, it's mapped to itself just like an executable, but xyplorer can't be aware of that. The fact that you brought up the %1 icon resource thing just suggests that you weren't aware of this, since you'd be aware that images don't work that way but executables do. And if you set a portable file icon for .exe or .msi or something, it will "cover up" the file's built-in icon resource, making all exe files look the same even if they have their own icon resource built-in. But like I said your post was a bit unclear, so if what you're trying to say is that you don't even have a *.ico rule defined in portable file icons, yet ico files are still not using their own icon resource for 16x16 previews, then that is not normal. That suggests that your .ico files have a broken icon handler subkey, or the extension has been associated with the wrong filetype. A lot of software installers do this, like adobe acrobat changes the filetype of the .pdf extension for example. That way it doesn't need to modify registry keys which will be overwritten with every windows update. So if you have some software that wants to open .ico files by default it's possible that it's changed your extension's filetype to some other filetype which does not use windows' ordinary icon handler. I'm not going to restate myself, if you want the solution to that it's in my first post.

Since you were so vague I can't tell what you're trying to do or whether you already have a *.ico rule defined. Are you trying to set a default .ico portable file icon, and then set a rule which overrides this for all non-blank or non-corrupt .ico files? It just doesn't make sense because .ico files are the only type of file which ALWAYS contain an icon resource. So there would never be a situation where you'd need to manually specify an icon resource for a .ico file, since xyplorer treats .ico files the same way windows explorer does. It uses the default icon handler to display the file's contents as the preview, just like it does with executables. Like I said before, it depends on whether you have set some rule already. Any wildcard rule you set in portable file icons is going to override the icon handler. So if you said *.ico>"defaulticon.ico" and now you're trying to add more specific rules to override it, that's just pointless. So it's hard to imagine that's what you're trying to do, so I gave you the other answer, assuming that you're just trying to get xyplorer to display ico files the way it's supposed to by default. If you haven't set any .ico PFI rules already and it's still not showing the file's contents as its icon preview, then you definitely have a problem in the registry. My original post goes into pretty much every possible registry key that could be causing it. There are other possibilities, like a corrupt windows update broke the icon handler itself, but I think if that happened you'd have noticed a lot of other problems by now. I think the most likely cause is the one that happens all the time, your .ico registry settings are borked. Either something has changed the DefaultIcon or IconHandler subkeys, or something has changed .ico's filetype to some filetype which itself has the wrong subkeys. I feel like this should be obvious but I'm saying your problem is not in xyplorer, it's in windows. xyplorer only uses portable file icons if you tell it to. By default it uses the same icon handler that file explorer uses. If you're even asking this question in the first place then it seems to everyone like you're not aware that this isn't something you need to set manually, it's how xyplorer already works. And xyplorer grabs the icon preview settings from the same registry subkeys that shell does... the ones I listed in my first post. So if you're not seeing the ico previews then obviously it is because of registry keys.
Last edited by aminomancer on 11 Jul 2019 16:26, edited 1 time in total.

autocart
Posts: 758
Joined: 26 Sep 2013 15:22

Re: Custom/Portable File Icons and .ico extension

Post by autocart » 11 Jul 2019 16:24

I am sorry but I am not reading *such* huge unstructured paragraphs.
customInlineRenameKeys ("OldStyle", "Mouse++" and "Ultimate"), clipboardHelper_and_XYEscToList

aminomancer
Posts: 14
Joined: 26 May 2019 06:29

Re: Custom/Portable File Icons and .ico extension

Post by aminomancer » 11 Jul 2019 16:38

autocart wrote:
11 Jul 2019 16:24
I am sorry but I am not reading *such* huge unstructured paragraphs.
The best I can abbreviate it is that xyplorer's file icon system already uses dynamic icon handlers. That is the default behavior as you can see in my screenshot. If you're not getting that behavior already then there's a problem with the DefaultIcon or IconHandler subkeys for keys .ico in your registry. One of three different hives. What you said in your first post also doesn't make sense. Changing the default "open with" program for a .ico file does NOT change the iconhandler. They are two different subkeys. Whatever program you installed didn't just change the "open with" program, it changed the defaulticon or iconhandler too. It doesn't need to and it shouldn't.

So you are actually wasting your time trying to solve it in xyplorer. All you need to do is reset .ico to normal, following the instructions I laid out. If that is too hard for you to read, use google and search "fix file icons." It's a really trivial problem but you're missing the basic solution because of your assumption that the icon is somehow coupled with the "open with" program. There's a really simple, easy to use tool available for exactly this purpose called FileTypesMan. And another called Default Programs Editor. Both of these can 1) easily fix your problem, and 2) show you that "open with" program is a completely different subkey from "DefaultIcon" or "IconHandler"

Are these paragraphs small enough? Honestly it's hard to imagine a person whose instinctive reaction to someone donating his time and help is to ridicule him for posting too much information. Can you not see how rude that is? You're ASKING for help, and then you just shit on the only person who offers to help you because his post is too long. it's baffling

EDIT: oh and I recognize why you'd think icons are coupled with default programs. The most common way of changing default programs for an extension in windows also happens to change the icon most of the time. So you might think if you change the default program for PDFs to chrome then the icon will change, and that does happen I think. But that's because the way the new windows 10 default programs module changes default programs is by changing the filetype entirely. It just moves .pdf from the nameless filetype to a named filetype which just so happens to have its own DefaultIcon defined. But if you manually set the default program yourself, it does not do this. You can do it in the registry manually or you can use one of the apps I mentioned.

Basically instead of switching the .ico extension to a different filetype, you're leaving it in the same filetype, but you're changing that filetype's "open with" path. Since your .ico is already messed up, you should use FileTypesMan to determine the file type name, and then just change the icon resource to %1 again. Whatever the new file type has it set to, it's not %1, or the MIME type is not image/x-icon. That's all you have to do, unless you have a really specific corruption of some DLL file. I guess you could run chkdsk if this fails.

aminomancer
Posts: 14
Joined: 26 May 2019 06:29

Re: Custom/Portable File Icons and .ico extension

Post by aminomancer » 11 Jul 2019 16:51

But if you're really stubborn and just insist that nothing is wrong with your registry or just refuse to read anything I wrote, I think you might technically be able to circumvent this issue by using
*.ico>*.ico
However, I think that will only work if the ico in question is the only ico file in the directory. It works for different filetypes, like you could set *.ini>*.ico and it'll use the corresponding ico for the ini file.

Also, this is not solving the underlying problem. It's just covering up the problem with a jury rigged solution, and I'm not even sure it works at all.

autocart
Posts: 758
Joined: 26 Sep 2013 15:22

Re: Custom/Portable File Icons and .ico extension

Post by autocart » 11 Jul 2019 20:12

autocart wrote:
03 Jun 2019 18:28
In Windows that is normally the standard using "%1" as icon recource, as far as I saw, but of course it can happen that a user defined program for opening and thus a different icon is set in the registry.
All I wrote is that this *can* happen, describing what I observed in real life.
I would like to use the icon file as its own file icon in a portable file icons definition in order to be able to use this also in a portable "installation" of XY so that it does not matter what settings the target system has. In my own system, everything is ok.

EDIT:
The help says:
Tip: Let all XYI files show the system icon of INC files:
+*.xyi>*.inc
That means that *.ico>*.ico would just assign the system setting of ico files to ico files, i.e. having no effect at all.
customInlineRenameKeys ("OldStyle", "Mouse++" and "Ultimate"), clipboardHelper_and_XYEscToList

jupe
Posts: 1126
Joined: 20 Oct 2017 21:14
Location: 1903 x64

Re: Custom/Portable File Icons and .ico extension

Post by jupe » 12 Jul 2019 01:37

aminomancer wrote:
09 Jul 2019 05:53
But if I set a portable file icon for *.exe it will override all the built-in icons for every .exe file.
FYI: viewtopic.php?f=5&t=20548#p170389

SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Custom/Portable File Icons and .ico extension

Post by SammaySarkar » 12 Jul 2019 06:05

autocart wrote:
11 Jul 2019 20:12
I would like to use the icon file as its own file icon in a portable file icons definition in order to be able to use this also in a portable "installation" of XY so that it does not matter what settings the target system has. In my own system, everything is ok.
I think you're trying to achieve this is a roundabout way. Maybe Don would like to add a config switch to ignore registry-defined icon for *.ico files.

For the time being, another solution could be to launch XY with one of those portable wrappers (like PortableApps), with custom registry overrides for HKCR\.ico

autocart
Posts: 758
Joined: 26 Sep 2013 15:22

Re: Custom/Portable File Icons and .ico extension

Post by autocart » 12 Jul 2019 11:42

SammaySarkar wrote:
12 Jul 2019 06:05
Maybe Don would like to add a config switch to ignore registry-defined icon for *.ico files.
I don't understand. If an PFI is defined then the registry setting for those files is ignored anyway. All it needs for the PFI definition is a working reference to itself equivalent to "%1" in the windows registry.

If just the registry is ignored, which icon will then be displayed? Probably some generic icon but I doubt that it will be the icon of the icon file itself.
customInlineRenameKeys ("OldStyle", "Mouse++" and "Ultimate"), clipboardHelper_and_XYEscToList

aminomancer
Posts: 14
Joined: 26 May 2019 06:29

Re: Custom/Portable File Icons and .ico extension

Post by aminomancer » 14 Jul 2019 00:17

autocart wrote:
12 Jul 2019 11:42
SammaySarkar wrote:
12 Jul 2019 06:05
Maybe Don would like to add a config switch to ignore registry-defined icon for *.ico files.
I don't understand. If an PFI is defined then the registry setting for those files is ignored anyway. All it needs for the PFI definition is a working reference to itself equivalent to "%1" in the windows registry.

If just the registry is ignored, which icon will then be displayed? Probably some generic icon but I doubt that it will be the icon of the icon file itself.
oh, I think I see what you're saying. You just want xyplorer to have a variable that basically amounts to a self-reference, and there definitely is no documented variable like that for the syntax used for file associations, icons, etc. At least, there's not a documented, clean way to do that. You definitely could do this with a script that generates individualized and temporary PFI rules per-file, but that "feels" kind of dirty. Really it would not be doing anything different from what the existing icon handler already does. Maybe depending on how you script it, it could be a little slower or a little faster. But who knows how to make such elaborate background scripts as perfectly stable as the system icon handler. But ironically even though you could do that with a script, simply having a variable like %1 would make it a lot easier to make scripts for dynamic file icons. Like file icons which change depending on some file property's string. I would say you should private message admin since it's possible there are undocumented variables that no one else would be aware of. And if not, it would be a good feature for a beta.

aminomancer
Posts: 14
Joined: 26 May 2019 06:29

Re: Custom/Portable File Icons and .ico extension

Post by aminomancer » 14 Jul 2019 00:18

jupe wrote:
12 Jul 2019 01:37
aminomancer wrote:
09 Jul 2019 05:53
But if I set a portable file icon for *.exe it will override all the built-in icons for every .exe file.
FYI: viewtopic.php?f=5&t=20548#p170389
Thanks so much this is pretty life-changing lol

Post Reply