Opening the Shell File/Folder Properties Dialog
-
Hi, Is there any way to programmatically open the Shell file/folder properties dialog for a given file? Is it possible to open this dialog to a given tab? Thanks, DigitalKing
-
Hi, Is there any way to programmatically open the Shell file/folder properties dialog for a given file? Is it possible to open this dialog to a given tab? Thanks, DigitalKing
DigitalKing wrote:
Is there any way to programmatically open the Shell file/folder properties dialog for a given file?
Yes.[^] :) [edit] Sorry - I was hasty in posting this note. See this[^] link instead. You'll need to convert the code to C#. [/edit] /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
-
DigitalKing wrote:
Is there any way to programmatically open the Shell file/folder properties dialog for a given file?
Yes.[^] :) [edit] Sorry - I was hasty in posting this note. See this[^] link instead. You'll need to convert the code to C#. [/edit] /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
Great! Thanks. In case anyone else is interested, here's the code I came up with.
private const uint SW_SHOW = 5;
private const uint SEE_MASK_INVOKEIDLIST = 0xC;
private struct SHELLEXECUTEINFO
{
public int cbSize;
public uint fMask;
public IntPtr hwnd;
public string lpVerb;
public string lpFile;
public string lpParameters;
public string lpDirectory;
public uint nShow;
public uint hInstApp;
//optional fields
public string lpIDList;
public string lpClass;
public IntPtr hkeyClass;
public IntPtr dwHotKey;
public IntPtr hIcon;
public IntPtr hProcess;
}[DllImport("shell32.dll")]
private static extern long ShellExecuteEx(ref SHELLEXECUTEINFO s);public static void DisplayFileProperties(string path)
{
SHELLEXECUTEINFO shInfo = new SHELLEXECUTEINFO();
shInfo.lpFile = path;
shInfo.nShow = SW_SHOW;
shInfo.fMask = SEE_MASK_INVOKEIDLIST;
shInfo.lpVerb = "properties";
shInfo.cbSize = Marshal.SizeOf(shInfo);
ShellExecuteEx(ref shInfo);
}