Link to home
Start Free TrialLog in
Avatar of jwh
jwh

asked on

How to get file's and directory's properties sheets

 In "Windows Explorer" when we right-click on some file or directory item, we can get its shortcut menu,in which there are a item named as "Properties". If we select this item, windows will show us a properties  sheet of the file.
  I want to get the "properties" sheet in my own program. Can anyone tell  me how to implement  it?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW: This works for NT ans should work for Win9x also. If not, you might want to take a look at

'http://www.geocities.com/SiliconValley/4942/common.html'

This _undocumented_ function will do the same:
"Displaying Object Properties
 
The last function I'm going to deal with in this section is
SHObjectProperties. This is what you would use to display
the properties dialog for a file or folder. It can also be used
to display the properties for a printer object. The ordinal
value is 178 and the function declaration looks like this:
 
   BOOL WINAPI SHObjectProperties(
     HWND    hwndOwner, 
     UINT    uFlags, 
     LPCSTR  lpstrName, 
     LPCSTR  lpstrParameters);
 
      hwndOwner identifies the window that owns the dialog.
lpstrName points to a string containing the path
name or the printer name whose properties
will be displayed. uFlags specifies the type of
name contained in lpstrName (see Figure 5).
lpstrParameters points to a string containing   
OPF_PRINTERNAME 0x01
OPF_PATHNAME 0x02
Figure 5  SHObjectProperties Flags
 
 
 
the name of the page that will initially be selected. If lpstr-
Parameters is NULL, the first page on the property sheet
will be selected.
      If the function succeeds, the return value is TRUE. If
the function fails, the return value is FALSE. To get exten-
ded error information, call GetLastError. Note that this
dialog is actually modeless, so when the function returns the
dialog will probably still be open. There is no way of kno-
wing when the user has closed the dialog.
      I should also mention that if you only need to display
the properties for a file or folder, you can quite easily ac-
complish the same thing with a call to the documented
function ShellExecuteEx, specifying "properties" for the
lpVerb parameter. This doesn't appear to work for printer
names though.   "
Sorry,

 sei.lpFile = "<the file's mame>";

should of course read

 sei.lpFile = "<the file's name>";

;-)