VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create File association in 10 lines of code (VerySimple)

by BrijMohan k (1 Submission)
Category: Registry
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 6th February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create File association in 10 lines of code (VerySimple)

API Declarations



In a form place the following code

Rate Create File association in 10 lines of code (VerySimple)



associate ".jpg", "JPGFile", "C:\Program Files\Accessories\MSPAINT.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
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


Download this snippet    Add to My Saved Code

Create File association in 10 lines of code (VerySimple) Comments

No comments have been posted about Create File association in 10 lines of code (VerySimple). Why not be the first to post a comment about Create File association in 10 lines of code (VerySimple).

Post your comment

Subject:
Message:
0/1000 characters