Displaying the File Properties Dialog


Author: Lothar A. Haensler

Displaying the File Properties Dialog

This code shows how to display the file properties dialog through VB5/6 Code.

screen shot

Paste the following code into a module in your project:


option Explicit
'
private Const SW_SHOW = 5
private Const SEE_MASK_INVOKEIDLIST = &HC
private Type SHELLEXECUTEINFO
    cbSize as Long
    fMask as Long
    hwnd as Long
    lpVerb as string
    lpFile as string
    lpParameters as string
    lpDirectory as string
    nShow as Long
    hInstApp as Long
    ' optional fields
    lpIDList as Long
    lpClass as string
    hkeyClass as Long
    dwHotKey as Long
    hIcon as Long
    hProcess as Long
End Type

private Declare Function ShellExecuteEx Lib "shell32.dll" _
    (byref s as SHELLEXECUTEINFO) as Long

public Sub DisplayFileProperties(byval sFullFileAndPathName as string)
    Dim shInfo as SHELLEXECUTEINFO
    
    With shInfo
        .cbSize = LenB(shInfo)
        .lpFile = sFullFileAndPathName
        .nShow = SW_SHOW
        .fMask = SEE_MASK_INVOKEIDLIST
        .lpVerb = "properties"
    End With
    
    ShellExecuteEx shInfo
End Sub

Now simply call the DisplayFileProperties routine with the full file and path name of the required file to display the properties.

Download Zipped Project File (5k)