Change a folder icon

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Change a folder icon

Post by keyless » Sun Jun 15, 2008 5:41 am

Is there a way to change a folder icon through a script (talking about in Windows, not in rev). I've looked for a VBscript, but haven't found one yet.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Jun 15, 2008 12:23 pm

Hi Keyless,

It must be possibly to do this using the registry, but I haven't found out how, yet. A little bit of information can be found here: http://vbrocks.net/vbstuff.htm
The icons you see every day in your Windows Explorer are not very nice. You can find some really neat on the Internet. Or you can even create your very own special icons using a handy tool such as Icon Easel.
To me there was a bigger problem not to paint them in eyecatching colors but actually install the icons so Windows starts using them. To display mine instead of those crazy ones.
The secret is buried in the Windows 2000 Registry. But not very deep.
Can you see the registry path in the piece of code below? That's it. But before you start copying the code I want to explain you something else.
All icons in the Windows Explorer have numbers. Here are some:
3- folder icon, 4- open folder icon, 30- trash can, etc.
If you have a simple program such as ResExplorer (from Borland) you can see what are the numbers of the icons in the Shell32.DLL file that resides in the System32 folder. Subtract 1 from the icon number you see in the DLL and you will have the number you can use in the Registry.
Now we are back to the Registry. If you've drawn your own Folder icon and want it to replace the Folder icon displayed by Windows you have to do the following.
- place your icon's .ICO file to a separate folder (needless to say, your icon file should contain at least 2 images- one 32x32 and one 16x16 pixels).
- start Notepad.EXE.
- copy and paste the following three lines into the Notepad. Replace "myfolder" and "myicon" with real names of the directory and file.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons]
"3"="c:\\myfolder\\myicon.ico,0"
and this icon will replace the one having #3 ,the Folder Icon
some notes: you have to replace a single backslash character with two of them when you work with Registry just like it is displayed in the line above, and you probably have to restart Windows (or restart the Explorer)
Unfortunately, this doesn't seem to apply to XP and Vista and I believe the information is incomplete, but at least this gives you an impression of what you need to look for.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Tue Jun 17, 2008 6:03 am

Thanks Mark for the lead, I'll look into it and let you know what I find.

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Wed Jun 18, 2008 5:32 am

This one turned out to be super easy, no reg or script needed. Info is all kept in a hidden file in each folder: Desktop.ini

one can make your own or edit a desktop.ini for a folder.

so I just create the file from rev. Contents of the file is this:

Code: Select all

[.ShellClassInfo]
IconFile=%USERPROFILE%\Desktop\Pictures\Purple.ico
IconIndex=0
nice and easy.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Jun 18, 2008 7:31 am

Hi Keyless,

That's very cool. Thanks for posting the solution here.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply