zoukankan      html  css  js  c++  java
  • c#代码启动任务管理器的几种方法

    1.直接启动

         ProcessStartInfo info = new ProcessStartInfo(); 
                info.FileName = Path.Combine(Environment.GetEnvironmentVariable("windir"), "explorer.exe");
                Process.Start(info).WaitForExit();
    

     2.类似1

                ProcessStartInfo info = new ProcessStartInfo();
                info.CreateNoWindow = true;
                info.UseShellExecute = true;
                info.WindowStyle = ProcessWindowStyle.Hidden;
                info.FileName = Path.Combine(Environment.GetEnvironmentVariable("windir"), "explorer.exe");
                Process.Start(info);
    

     3.shell 外部方法

       private void button1_Click(object sender, EventArgs e)
            {
                ShellExecute(IntPtr.Zero, null, "explorer.exe", null, null, ShowCommands.SW_SHOW);
            }
            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,
                string lpFile,
                string lpParameters,
                string lpDirectory,
                ShowCommands nShowCmd);
    

     4.shell窗口常规

       Process.Start(Path.Combine(Environment.GetEnvironmentVariable("windir"), "explorer.exe")); 
                ShellWindows  win= new SHDocVw.ShellWindows();
    

     5.cmd命令执行explorer.exe

     System.Diagnostics.Process process = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName = "cmd.exe"; 
                process.StartInfo = startInfo;
                process.StartInfo.RedirectStandardInput = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.UseShellExecute = false;
                process.Start();
                process.StandardInput.WriteLine(Environment.GetEnvironmentVariable("windir")+"\explorer.exe");
                process.StandardInput.Flush();
                process.StandardInput.Close();
                process.WaitForExit();
    

    感谢每一位阅读此篇文章的人,希望可以帮到你。

  • 相关阅读:
    nginx thinkphp rewrite配置项
    mysql主从配置,主从服务器都是全新安装myql的情景
    mysql提示启动成功,但statu是isstopped,重启后正常
    mysql怎么设置密码都不正确的一个解决方法
    linux统计文件个数及代码总行数
    mysqld启动失败时日志查看命令
    .tar.xz 的解压方式 centos
    CentOS 安装Erlang
    vector android:fillType gradient android:endX attribute not found
    found an invalid color
  • 原文地址:https://www.cnblogs.com/congqiandehoulai/p/5462654.html
Copyright © 2011-2022 走看看