VB icon

Show File Property Dialog

Email
Submitted on: 2/1/2015 9:03:00 PM
By: Edward Catchpole (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: VB 5.0, VB 6.0
Views: 1233
 
     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: http://www.mvps.org/vbnet/code/shell/propertypage.htm
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Show File Property Dialog
' Description: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: http://www.mvps.org/vbnet/code/shell/propertypage.htm
' By: Edward Catchpole (from psc cd)
'**************************************

Private Type SHELLEXECUTEINFO
cbSizeAs Long
fMask As Long
hwnd As Long
lpVerbAs String
lpFileAs String
lpParameters As String
lpDirectoryAs String
nShow As Long
hInstApp As Long
lpIDList As Long 'Optional
lpClassAs 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


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.