zoukankan      html  css  js  c++  java
  • ShellExecute调用另外一个进程(demo为一个控制led的一段代码)

     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
  • 相关阅读:
    CodeForces 706C Hard problem
    CodeForces 706A Beru-taxi
    CodeForces 706B Interesting drink
    CodeForces 706E Working routine
    CodeForces 706D Vasiliy's Multiset
    CodeForces 703B Mishka and trip
    CodeForces 703C Chris and Road
    POJ 1835 宇航员
    HDU 4907 Task schedule
    HDU 4911 Inversion
  • 原文地址:https://www.cnblogs.com/wygm/p/5668163.html
Copyright © 2011-2022 走看看