CreateFileAssociation – Associate a file extension to a program

CreateFileAssociation – Associate a file extension to a program

Private Declare Sub SHChangeNotify Lib "shell32.dll" (ByVal wEventId As Long, _    ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long)Const SHCNE_ASSOCCHANGED = &H8000000Const SHCNF_IDLIST = 0' Create the new file association'' Extension is the extension to be registered (eg ".cad"' ClassName is the name of the associated class (eg "CADDoc")' Description is the textual description (eg "CAD Document"' ExeProgram is the app that manages that extension (eg "c:CadMyCad.exe")'' NOTE: requires CreateRegistryKey and SetRegistryValue functionsSub CreateFileAssociation(ByVal Extension As String, ByVal ClassName As String, _    ByVal Description As String, ByVal ExeProgram As String)    Const HKEY_CLASSES_ROOT = &H80000000        ' ensure that there is a leading dot    If Left(Extension, 1) <> "." Then        Extension = "." & Extension    End If       ' create a new registry key under HKEY_CLASSES_ROOT    CreateRegistryKey HKEY_CLASSES_ROOT, Extension    ' create a value for this key that contains the classname    SetRegistryValue HKEY_CLASSES_ROOT, Extension, "", ClassName    ' create a new key for the Class name    CreateRegistryKey HKEY_CLASSES_ROOT, ClassName & "ShellOpenCommand"    ' set its value to the command line    SetRegistryValue HKEY_CLASSES_ROOT, ClassName & "ShellOpenCommand", "", _        ExeProgram & " ""%1"""    ' notify Windows that file associations have changed    SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0End Sub

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved