Change Extensions Icons

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
13 posts Page 2 of 2
Contributors
User avatar
troop
Dedicated Member
Dedicated Member
Posts: 75
Joined: Sat Sep 28, 2013 11:57 am

Re: Change Extensions Icons
troop
comathi wrote:
#troop

Once you have used those two lines of code both visualtech and I have sent you, use this to set an icon for your extension:
Code: Select all
My.Computer.Registry.ClassesRoot.CreateSubKey("Hello\DefaultIcon").SetValue("", """" filename.ico"", 0", Microsoft.Win32.RegistryValueKind.ExpandString)
Make sure you replace "Hello" with the name of the name of the folder you created previously (with the "\shell\command" line) and replace "filename.ico" with the filename of your icon file you wish to use.

As with everything when editing the registry, you may need to restart your computer so the changes can take place. Here's what it did for me:
Image

Thhx so much, hello should be my extension?
("extension\DefaultIcon") ??

also does this need run as admin i can do it my self but does it? also should it be a 1 time run code or doesnt matter if it repeats it on each form load? loove;
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Re: Change Extensions Icons
comathi
If your extension's name is "extension", then the full code you'll be using is this:
Code: Select all
My.Computer.Registry.ClassesRoot.CreateSubKey(".extension").SetValue("", "Extension", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Extension\shell\open\command").SetValue("", Application.ExecutablePath & " ""%l"" ", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Extension\DefaultIcon").SetValue("", """" filename.ico"", 0", Microsoft.Win32.RegistryValueKind.ExpandString)
All of this should be run as admin, and may require a computer restart since you're playing around with the registry.

As far as I know, running the code multiple times won't hurt anything :)
User avatar
troop
Dedicated Member
Dedicated Member
Posts: 75
Joined: Sat Sep 28, 2013 11:57 am

Re: Change Extensions Icons
troop
comathi wrote:
If your extension's name is "extension", then the full code you'll be using is this:
Code: Select all
My.Computer.Registry.ClassesRoot.CreateSubKey(".extension").SetValue("", "Extension", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Extension\shell\open\command").SetValue("", Application.ExecutablePath & " ""%l"" ", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Extension\DefaultIcon").SetValue("", """" filename.ico"", 0", Microsoft.Win32.RegistryValueKind.ExpandString)
All of this should be run as admin, and may require a computer restart since you're playing around with the registry.

As far as I know, running the code multiple times won't hurt anything :)
ThanX comathi loove;
13 posts Page 2 of 2
Return to “Coding Help & Support”