How to bring "Choose Program" screen of windows in our application
Dear All,
I need to bring 'Choose Program" screen of WINDOWS(to view..CTRL+Right Click+Open With..) in my application.Kindly guide me with some sample code.
Thanks and Regards,
V
Sam HobbsPosted Jun 22, 2011, 11:22 AM
jibin pjPosted Jun 22, 2011, 7:10 AM
[DllImport("shell32.dll", SetLastError = true,
EntryPoint = "ShellExecuteExW",
CharSet = CharSet.Unicode)]
static extern bool ShellExecuteEx(
ref SHELLEXECUTEINFO lpExecInfo);
[StructLayout(LayoutKind.Sequential)]
internal struct SHELLEXECUTEINFO
{
internal int cbSize;
internal uint fMask;
internal IntPtr hwnd;
[MarshalAs(UnmanagedType.LPWStr)]
internal string lpVerb;
[MarshalAs(UnmanagedType.LPWStr)]
internal string lpFile;
[MarshalAs(UnmanagedType.LPWStr)]
internal string lpParameters;
[MarshalAs(UnmanagedType.LPWStr)]
internal string lpDirectory;
internal int nShow;
internal IntPtr hInstApp;
internal IntPtr lpIDList;
[MarshalAs(UnmanagedType.LPWStr)]
internal string lpClass;
internal IntPtr hkeyClass;
internal uint dwHotKey;
internal IntPtr hIcon;
internal IntPtr hProcess;
}
public const uint SW_NORMAL = 1;
const int SEE_MASK_INVOKEIDLIST = 0x00000C;
const int SEE_MASK_NOCLOSEPROCESS = 0x000040;
const int SEE_MASK_FLAG_NO_UI = 0x000400;
static void OpenAs(string file)
{
SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO();
sei.cbSize = Marshal.SizeOf(sei);
sei.hwnd = IntPtr.Zero;
sei.fMask = (SEE_MASK_INVOKEIDLIST |
SEE_MASK_NOCLOSEPROCESS |
SEE_MASK_FLAG_NO_UI);
sei.lpVerb = "openas";
sei.lpFile = file;
sei.nShow = 1;
if (!ShellExecuteEx(ref sei))
throw new System.ComponentModel.Win32Exception();
}
vipin.sasiPosted Oct 27, 2003, 3:14 AM
tsuman_inPosted Oct 26, 2003, 1:06 AM
using System.ComponentModel; [DllImport("shell32.dll")] private static extends long ShellExecute(long hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, long nShowCmd) {} public static void ShowOpenWithDialog(string sFileName) { ShellExecute(0, vbNullString, "RUNDLL32.EXE", "shell32.dll,OpenAs_RunDLL " + sFileName, "", don't know this one:vbNormalFocus); }This should at least get you on your way. You'll have to figure out how to get the alias yourself, unless someone else knows the answer to that.vipin.sasiPosted Oct 25, 2003, 7:28 AM