ListFileExtensions – Retrieve information about all registered file extensions

' List all the File extensions that are registered in the system'' return a bi-dimension string array, where'    arr(0, i) is the file extension'    arr(1, i) is the coresponding ProgID'    arr(2, i) is the associated description'    arr(3, i) is the location of the executable file'' Example:'   ' fill a listbox with the descriptions associated '   ' to each registered file extension'   Dim a() As String, i As Long'   a() = ListFileExtensions()'   For i = 1 To UBound(a, 2)'       List1.AddItem a(0, i) & vbTab & a(2, i)'   Next'' NOTE: requires the EnumRegistryKey and GetRegistryValue functionsFunction ListFileExtensions() As String()    Dim regKeys As Collection    Dim regKey As Variant    Dim extsNdx As Long    Dim progID As String    Dim clsid As String        Const HKEY_CLASSES_ROOT = &H80000000        ' retrieve all the subkeys under HKEY_CLASSES_ROOT    Set regKeys = EnumRegistryKeys(HKEY_CLASSES_ROOT, "")        ' prepare the array of results    ReDim exts(3, regKeys.Count) As String        ' ignore errors    On Error Resume Next        For Each regKey In regKeys        ' check whether this is a File extension        If Left$(regKey, 1) = "." Then            ' store the extension in the result array            extsNdx = extsNdx + 1            exts(0, extsNdx) = regKey            ' the default value for this key is the ProgID            ' or another string that can be searched in the Registry            progID = GetRegistryValue(HKEY_CLASSES_ROOT, regKey, "")            exts(1, extsNdx) = progID            ' the default value of the key HKEY_CLASSES_ROOTProgID is            ' the textual description of this entry            exts(2, extsNdx) = GetRegistryValue(HKEY_CLASSES_ROOT, progID, "")            If exts(2, extsNdx) = "" Then                ' if this key doesn't exist, delete this array entry                extsNdx = extsNdx - 1            Else                ' else try to read the location of the associated EXE file                exts(3, extsNdx) = GetRegistryValue(HKEY_CLASSES_ROOT, _                    progID & "shellopencommand", "")            End If        End If    Next            ' trim unused items    ReDim Preserve exts(3, extsNdx) As String    ListFileExtensions = exts()End Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS