4 Replies - 1342 Views - Last Post: 24 February 2014 - 10:18 PM Rate Topic: -----

#1 zubair130  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-April 13

How can I change Icons?

Posted 24 February 2014 - 11:43 AM

Friends,

I am making a windows customizer. I want to change desktop icons like My Computer Icon, Documents Icon, Recycle Bin etc. and other icons. I can change folder icon with registry.

Any help?
Is This A Good Question/Topic? 0
  • +

Replies To: How can I change Icons?

#2 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1447
  • View blog
  • Posts: 3,682
  • Joined: 01-February 13

Re: How can I change Icons?

Posted 24 February 2014 - 01:26 PM

Hi,
You can change the desktop shortcut icons by using the Windows Scripting Host Object Model which is handy for creating new shortcuts and getting information from shortcuts also. You will need to add a reference to the Windows Scripting Host Object Model which i explain how at the top of the example code. You will need to have the full pathname of the icon you want to use and the full pathname of the shortcut. Sortcuts on the desktop don`t show the extension but, the use a .lnk extension.

You can create a shortcut on the desktop to test this out. I used "AniTuner.lnk" as my test shortcut.

'After starting your new project go to the VB menu and click (Project) then click (Add Refference...)
'When the window opens click the (Com) tab and scroll down and doubleclick (Windows Scripting Host Object Model).

Imports IWshRuntimeLibrary

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'This is the full Desktop path with my AniTuner.lnk file added on the path
        Dim ShortcutPathname As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "AniTuner.lnk")

        'Create a new WshShell object
        Dim scShell As New WshShell()

        'Get the shortcut
        Dim Shortcut As WshShortcut = CType(scShell.CreateShortcut(ShortcutPathname), WshShortcut)

        'Set the icon you want to use
        Shortcut.IconLocation = "C:\TestFolder\MyIcon.ico"

        'Save the changed shortcut
        Shortcut.Save()
    End Sub
End Class


Attached Image
Was This Post Helpful? 1
  • +
  • -

#3 zubair130  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-April 13

Re: How can I change Icons?

Posted 24 February 2014 - 08:40 PM

Thanks but how to change My Computer, Rcycle Bin Icon
Was This Post Helpful? 0
  • +
  • -

#4 thecoat  Icon User is offline

  • D.I.C Addict

Reputation: 153
  • View blog
  • Posts: 537
  • Joined: 07-December 13

Re: How can I change Icons?

Posted 24 February 2014 - 09:52 PM

The icon used by the recycle bin is stored in the following registry key.

Quote

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon


There is a string value for empty and full, and you change it to the path of your icon. Note that the default references a system library %SystemRoot%\System32\imageres.dll and passes it a numeric code for the correct icon, but I tried it with an .ico and it worked fine (have to log out and back in or possibly change the state of the recycle bin (empty it or delete something).
Was This Post Helpful? 0
  • +
  • -

#5 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 917
  • View blog
  • Posts: 2,358
  • Joined: 28-March 11

Re: How can I change Icons?

Posted 24 February 2014 - 10:18 PM

Once you change the icons, you need to update the icon cache that Windows uses. You will need to use SHChangeNotify

1st parameter = SHCNE_ASSOCCHANGED
2nd parameter = SHCNF_IDLIST or SHCNF_FLUSHNOWAIT or SHCNF_NOTIFYRECURSIVE
3rd and 4th = 0
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1