View Single Post
  #6 (permalink)  
Old 04-18-2009, 11:25 PM
rdavidsmith's Avatar
rdavidsmith
Regular 'Geeker
Offline
Threadstarter
Location: Tha South
 
Join Date: Feb 2008
Posts: 372
Reputation: 1830
rdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on reprdavidsmith is halfway to VIP status based on rep
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: Cool Vista Folders

I had access to this and yeah im a bonehead for not sharing...

I just wanted to let you in on a little trick regarding setting folder icons.

There are two ways to do it, you have used method #1.

Both methods involve placing a file called ICON.LNK inside the folder. ICON.LNK is just a plain text file with the following contents:

Method #1:

1#\Windows\Vista Folders.dll,-1
  • 1# is standard, and should always be there
  • \Windows\Vista Folders.dll is the path to the dll file which has your icons.
  • -1 is the index number of which icon to use in the dll starts at 1 and can be as high as you have icons in the .dll. Always put a "-" in front. So, if it is icon index 9 it would be -9.
I am explaining this here for anyone that is curious what you are doing. Now, on to the next method:

Method #2:

The method works as above, with the ICON.LNK file in the folder you wish to set the icon for, however the contents of the ICON.LNK look more like this:

1#:MYICON_1

Looks strange, right? Well, just like above the #1 is standard and should not be changed. What about this MYICON_1 then?

Well, this actually points to a location in the registry that looks like this:

Code: Select all[HKEY_CLASSES_ROOT\MYICON_1\DefaultIcon]
@="\Windows\Vista Folders.dll,-1"
[HKEY_CLASSES_ROOT\MYICON_1\SelectIcon]
@="\Windows\Vista Folders.dll,-1"

So the icon.lnk file is actually pointing to a HKCR entry in the registry which them maps it to the DLL and index number.

So, why choose one method over another? Well there aren't too many reasons. One reason may be that when you are making a CAB file, the user may not install the DLL in the location you think it will be...so a hardcoded location inside the ICON.LNK file won't work. However, .CAB files can support replaceable paramaters like %InstallDir% which allow you to expand the installation location in the registry. So, when the CAB gets installed (say to the storage card instead of device memory), the CAB installation can automatically change this:

Code: Select all[HKEY_CLASSES_ROOT\MYICON_1\DefaultIcon]
@="%InstallDir%\Vista Folders.dll,-1"
[HKEY_CLASSES_ROOT\MYICON_1\SelectIcon]
@="%InstallDir%\Vista Folders.dll,-1"

To this:
Code: Select all[HKEY_CLASSES_ROOT\MYICON_1\DefaultIcon]
@="Storage Card\My Folder\Vista Folders.dll,-1"
[HKEY_CLASSES_ROOT\MYICON_1\SelectIcon]
@="Storage Card\My Folder\Vista Folders.dll,-1"

For the most part, it is preference. Some people may think it is cleaner NOT to use the registry, but the registry method can also allow an easier remaping. For instance you can just edit the registry entry than edit the ICON.LNK file, which might be easier in some cases (programmatically).

It's surprising that I haven't seen a little app that allows you to easily do this. It would need to be able to browse a .dll icon library on the device and then simply write the icon.lnk file and/or a reg file (depending on method used).
__________________


IF I WAS HELPFUL HIT THE BUTTON!!
Reply With Quote