码迷,mamicode.com
首页 > Windows程序 > 详细

c#代码启动任务管理器的几种方法

时间:2016-05-05 19:10:18      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

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();

 

c#代码启动任务管理器的几种方法

标签:

原文地址:http://www.cnblogs.com/lizhijian/p/5462654.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!