Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB6
Expertise: Intermediate
Jun 23, 2003

Changing the icon of a drive

By editing the Registry it is possible to change the icon that Windows Explorer uses for a drive. For example, if you want to change Drive E's icon, create the following registry key:

HEKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Current Version\Explorer\DriveIcons\E\DefaultIcon\

When you create the above key, a string value named "Default" with value not set is automatically created. What you have to do is setting this value with the path of the icon, and this changes the drive icon of Drive E.

If you want revert back the default Icon, just delete the value of the "Default" string value, or just delete the above registry key. Here are two reusable routines to set or reset the icon for a specified drive:


Sub ChangeDriveIcon(ByVal driveLetter As String, ByVal icoPath As String)
    Dim regKey As String
    regKey = "Software\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\" & _
        driveLetter & "\DefaultIcon"
    
    ' create the parent key
    CreateRegistryKey HKEY_LOCAL_MACHINE, regKey
    ' set the (Default) value with the icon's path
    SetRegistryValue HKEY_LOCAL_MACHINE, regKey, "", icoPath
End Sub

Sub ResetDriveIcon(ByVal driveLetter As String)
    Dim regKey As String
    regKey = "Software\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\" & _
        driveLetter & "\DefaultIcon"
        
    ' delete the key
    DeleteRegistryKey HKEY_LOCAL_MACHINE, regKey
End Sub
Pampati Praveenp
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date