C# Example of Property Dialog
Just added to http://pinvoke.net
http://pinvoke.net/default.aspx/shell32/ShellExecuteEx.html
Using ShellExecuteEx to show the properties dialog box of a file.
public static void ShowFileProperties(string Filename) {
SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info);
info.lpVerb = "properties";
info.lpFile = Filename;
info.nShow = SW_SHOW;
info.fMask = SEE_MASK_INVOKEIDLIST;
ShellExecuteEx(ref info);
}
private const int SW_SHOW = 5;
private const uint SEE_MASK_INVOKEIDLIST = 12;
[DllImport("shell32.dll")]
static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SHELLEXECUTEINFO
{
public int cbSize;
public uint fMask;
public IntPtr hwnd;
public String lpVerb;
public String lpFile;
public String lpParameters;
public String lpDirectory;
public int nShow;
public int hInstApp;
public int lpIDList;
public String lpClass;
public int hkeyClass;
public uint dwHotKey;
public int hIcon;
public int hProcess;
}
7 Comments
Comments have been disabled for this content.
Smith said
Exactly what I was looking for. Much appreciated.
Mahesh Bagul said
It works but I want it to show for multiple files? Any help?
alexch said
The SHELLEXECUTEINFO presented is valid only for Win32 (some "int" must be "IntPtr"); it should look like: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct SHELLEXECUTEINFO { public int cbSize; public uint fMask; public IntPtr hwnd; public String lpVerb; public String lpFile; public String lpParameters; public String lpDirectory; public int nShow; public IntPtr hInstApp; public IntPtr lpIDList; public String lpClass; public IntPtr hkeyClass; public uint dwHotKey; public IntPtr hIcon; public IntPtr hProcess; }
Mikkel said
Is there any way of making the Property window TopMost like BringToFront()?
Md. Rashim Uddin said
How do we make it working for multiple selected file?
Harish said
Using SHELLEXECUTEINFO i am opening an application. How do i make the SHELLEXECUTEINFO make wait till the child application is closed?
Steph said
Using "Charset = Charset.Auto" gives me an errormessage with chinese or whatever symbols... *lol*