devxlogo

DeleteFileAssociation – Unregister a file extension

DeleteFileAssociation – Unregister a file extension

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' Destroy a file association'' NOTE: requires the GetRegistryValue and DeleteRegistryKey functionsSub DeleteFileAssociation(ByVal Extension As String)    Dim ClassName As String        Const HKEY_CLASSES_ROOT = &H80000000        ' ensure that there is a leading dot    If Left(Extension, 1)  "." Then        Extension = "." & Extension    End If    ' read the associated class name    ClassName = GetRegistryValue(HKEY_CLASSES_ROOT, Extension, "")    ' exit if there is no extension association    If Len(ClassName) = 0 Then Exit Sub        ' delete this key    DeleteRegistryKey HKEY_CLASSES_ROOT, Extension    ' delete the other key where registration data is found    DeleteRegistryKey HKEY_CLASSES_ROOT, ClassName    ' notify Windows that file associations have changed    SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0End Sub

devx-admin

Share the Post: