public enum ShowCommands : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}
[DllImport("shell32.dll")]
static extern IntPtr ShellExecute(
IntPtr hwnd,//父窗口的句柄
string lpOperation,//指定动作, 譬如: open、runas、print、edit、explore、find
string lpFile,//指定要打开的文件或程序
string lpParameters,// { 给要打开的程序指定参数; 如果打开的是文件这里应该是 nil}
string lpDirectory,//用于指定默认目录
ShowCommands nShowCmd);
使用样例:
IntPtr t = ShellExecute(IntPtr.Zero, "open", "H:\Sublime\pro\test\page\WebApplication1\WebApplication1\page\LedTest.exe",Ip + ' ' + @"c:1.txt" + ' '+ ledtype, null, ShowCommands.SW_SHOWNORMAL);
传入多个参数时:Ip + ' ' + @"c:1.txt" + ' '+ ledtype