dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Feb 17, 2001

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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 = &H8000000
Const SHCNF_IDLIST = 0

' Destroy a file association
'
' NOTE: requires the GetRegistryValue and DeleteRegistryKey functions

Sub 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, 0
End Sub
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date