devxlogo

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

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.