Use the System's File Properties Dialog
Invoke the Windows standard property dialog for any given file.
by Karl E. Peterson
Technology Toolbox: VB6, VB5
Q: Use the System's File
My application offers a display of filenames as part of its user interface. I'd like to give users the ability to bring up the system File Properties dialog as one of the options when they right-click on a filename. How can I do that?
Set up the call by creating a SHELLEXECUTEINFO structure and filling its first element (cbSize) with the structure's overall size so the system knows that you know what you're doing. Create the flag mask by combining the constant values for SEE_MASK_INVOKEIDLIST (which allows the use of shortcut menu extension verbs, rather than only Registry verbs), SEE_MASK_FLAG_NO_UI (which prevents the system from popping message boxes on errors), and SEE_MASK_DOENVSUBST (which expands environment variables in the passed filespec).
It's good form to stuff the structure's hWnd element with the handle of a window in your app. This window serves as the parent of any error-related message boxes the system pops up, although you've instructed the system already not to do this. The lpVerb element is the key to bringing up the desired dialog—assign "properties" to this element. Finally, assign the desired filename to the lpFile element, and make the call to ShellExecuteEx.
You can gauge your call's success by examining the SHELLEXECUTEINFO structure's hInstApp element for a value greater than 32. Values less than 32 indicate an error occurred, and you can interpret the exact cause from the specific value. —K.E.P.
About the Author