Results 1 to 2 of 2

Thread: Any1 Know How 2 Get The Windows Programs List

  1. #1

    Thread Starter
    Lively Member mrdarkwarez's Avatar
    Join Date
    Feb 2000
    Location
    Australia
    Posts
    113

    Post

    Does any one how to get the windows registered program list up, the one where u click on open with.... in the menu of unregistered files.

    Is there information in the registry where I can obtain those program or some other way??

    any help would be aprricated
    thanks

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Here's an example I put together, which lists all registered Extensions and their associated icons:
    Code:
    'Add a Listbox and a Picturebox to a Form...
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Private Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
    Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
    Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
    
    Private Const HKEY_CLASSES_ROOT = &H80000000
    
    Private aIcons() As String
    
    Private Sub Form_Load()
        Dim sType As String        'Ext.
        Dim sName As String        'Name of File Type
        Dim sFile As String        'File Used For Default Icon
        Dim iIndex As Long
        Dim lRegKey As Long
        Dim iFound As Long
        
        List1.FontName = "Courier"
        iIndex = 1
        sType = Space(255)
        'Enumerate all Extensions in the CLASSES Hive..
        Do While RegEnumKey(HKEY_CLASSES_ROOT, iIndex, ByVal sType, 255) = 0
            If Left(sType, 1) = "." Then
                'Store Icon Info in an Array Linked by ListIndex
                ReDim Preserve aIcons(iFound)
                sType = Left(sType, InStr(sType, Chr(0)) - 1)
                'Get this Extensions Name, eg - .zip = WinZip
                If RegOpenKey(HKEY_CLASSES_ROOT, ByVal sType, lRegKey) = 0 Then
                    sName = Space(255)
                    Call RegQueryValueEx(lRegKey, ByVal "", 0&, 1, ByVal sName, 255)
                    If InStr(sName, Chr(0)) Then sName = Left(sName, InStr(sName, Chr(0)) - 1)
                    Call RegCloseKey(lRegKey)
                    If Len(Trim(sName)) Then
                        'Look for a Default Icon for this Type..
                        If RegOpenKey(HKEY_CLASSES_ROOT, sName & "\DefaultIcon\", lRegKey) = 0 Then
                            sFile = Space(255)
                            Call RegQueryValueEx(lRegKey, ByVal "", 0&, 1, ByVal sFile, 255)
                            If InStr(sFile, Chr(0)) Then sFile = Left(sFile, InStr(sFile, Chr(0)) - 1)
                            Call RegCloseKey(lRegKey)
                            aIcons(iFound) = sFile
                        End If
                    End If
                End If
                iFound = iFound + 1
                List1.AddItem Left(sType & Space(10), 10) & " - " & sName
            End If
            sType = Space(255)
            iIndex = iIndex + 1
        Loop
    End Sub
    
    Private Sub List1_Click()
        Dim sFile As String
        Dim iIndex As Integer
        Dim lIcon As Long
        
        Picture1.Cls
        On Error GoTo IconErr
        'Get the Icon from the File Stored in the Array for this File Type
        sFile = Left$(aIcons(List1.ListIndex), InStr(aIcons(List1.ListIndex), ",") - 1)
        iIndex = Val(Mid$(aIcons(List1.ListIndex), InStr(aIcons(List1.ListIndex), ",") + 1))
        lIcon = ExtractIcon(App.hInstance, sFile, iIndex)
        Call DrawIconEx(Picture1.hdc, 0, 0, lIcon, 32, 32, 0, 0, 3)
    IconErr:
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width