VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Show File Property Dialog

by Edward Catchpole (6 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

This function will display the file property dialog for any file you specify - it is the same one that Windows Explorer shows when you right click and goto 'Properties'.
The original article can be found at: https://www.mvps.org/vbnet/code/shell/propertypage.htm

Rate Show File Property Dialog

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
  lpIDList   As Long   'Optional
  lpClass    As String  'Optional
  hkeyClass   As Long   'Optional
  dwHotKey   As Long   'Optional
  hIcon     As Long   'Optional
  hProcess   As Long   'Optional
End Type
Private Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
Private Const SEE_MASK_FLAG_NO_UI = &H400
Private Declare Function ShellExecuteEx Lib "shell32" _
  Alias "ShellExecuteExA" _
 (SEI As SHELLEXECUTEINFO) As Long
 
Private Sub Form_Load()
  Command1.Caption = "Show Properties"
  
 'assure string points to a valid file
 'on your system
  Text1.Text = "c:\windows\notepad.exe"
 
End Sub

Private Sub Command1_Click()
 
 'show the properties dialog, passing the filename
 'and the owner of the dialog 
  Call ShowProperties(Text1.Text, Me.hwnd) 
End Sub

Private Sub Command2_Click()
  
  Unload Me
  
End Sub

Private Sub ShowProperties(sFilename As String, hWndOwner As Long)
 
 'open a file properties property page for 
 'specified file if return value
  Dim SEI As SHELLEXECUTEINFO
 
 'Fill in the SHELLEXECUTEINFO structure 
  With SEI
   .cbSize = Len(SEI)
   .fMask = SEE_MASK_NOCLOSEPROCESS Or _
        SEE_MASK_INVOKEIDLIST Or _
        SEE_MASK_FLAG_NO_UI
   .hwnd = hWndOwner
   .lpVerb = "properties"
   .lpFile = sFilename
   .lpParameters = vbNullChar
   .lpDirectory = vbNullChar
   .nShow = 0
   .hInstApp = 0
   .lpIDList = 0
  End With
 
 'call the API to display the property sheet 
  Call ShellExecuteEX(SEI)
 
End Sub

Download this snippet    Add to My Saved Code

Show File Property Dialog Comments

No comments have been posted about Show File Property Dialog. Why not be the first to post a comment about Show File Property Dialog.

Post your comment

Subject:
Message:
0/1000 characters