Jump to content

File Icon in registry


Recommended Posts

Where in the registry can I change the icon for a specific file extention?

For example, if I want the file extension ".msd" to be something like "icon.ico" how can I do this through the registry?

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Link to comment
Share on other sites

Example: Quick and dirty.

#include "Array.au3"
$filepath = "C:\WINDOWS\system32\user32.dll"
_ArrayDisplay (FileGetIcon ($filepath))


Func FileGetIcon ($file, $opt = 1)
    $string = StringSplit ($file, ".")
    If Not IsArray ($string) Then Return SetError (0, 0, 0)
    $ext = "." & $string[$string[0]]
    $key = RegRead ("HKCR\" & $ext, "")
    If @error Then Return SetError (0, @extended, 0)
    $icon = RegRead ("HKCR\" & $key & "\DefaultIcon", "")
    If @error Then Return SetError (0, @extended, 0)
    
    If $opt = 1 Then
        Local $arr[2]
        $ret2 = StringSplit ($icon, ",")
            $arr[0] = $ret2[1]
            $arr[1] = $ret2[2]
    Else
        $arr = $icon
    EndIf
    Return SetError (1, 0, $arr)
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...