How do I allocate a icon to a unknown file extension through code???
How do I allocate a icon to a unknown file extension through code???
unknown filextension ?
please, can u make it clear
if file extension is known you can allocate an icon to it
I create a file with a file extension for example .krs.
Now I want to add this file extension to the registry.
So for I can do that, but I want to allocate a icon to the files with that file extension. I got it working but now I cant seem to get it right again.
I think that you should associate the extension correctly in the registry.also you could change the registry key below if you want to change the associated icon
"HKEY_CLASSES_ROOT\Mari\DefaultIcon" with correct path of the icon in the "Default" string value
Please try this code
Private Sub Form_Load()
associate ".krs", "Mari", "C:\MARI.EXE"
Unload Me
End Sub
Public Sub associate(EXT As String, FileType As String, FileName As String)
On Error Resume Next
Dim b As Object
Set b = CreateObject("wscript.shell")
b.regwrite "HKCR\" & EXT & "\", FileType
b.regwrite "HKCR\" & FileType & "\", "MY file"
b.regwrite "HKCR\" & FileType & "\DefaultIcon\", FileName ' Here you should specify the path 0f the icon
b.regwrite "HKCR\" & FileType & "\shell\open\command\", FileName & " %L"
b.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\Application"
b.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\Application", FileName
b.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\OpenWithList\"
b.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\OpenWithList\a", FileName
End Sub