青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++ Programmer's Cookbook

{C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

進程 Process的使用

1 Process?
? 簡單實例:

// ?Execute?notepad.exe?with?no?command-line?arguments.
Process.Start( " notepad.exe " );

// ?Execute?notepad.exe?passing?the?name?of?the?file?to?open?as?a?
// ?command-line?argument.
Process.Start( " notepad.exe " ,? " SomeFile.txt " );

Properties of the ProcessStartInfo Class

Property

Description

Arguments

The command-line arguments to pass to the new process.

ErrorDialog

If Process.Start can't start the specified process, it will throw a System.ComponentModel.Win32Exception. If ErrorDialog is true, Start displays an error dialog to the user before throwing the exception.

FileName

The name of the application to start. You can also specify any type of file for which you have configured an application association. For example, you could specify a file with a .doc or .xls extension, which would cause Microsoft Word or Microsoft Excel to run.

WindowStyle

A member of the System.Diagnostics.ProcessWindowStyle enumeration, which controls how the window is displayed. Valid values include Hidden, Maximized, Minimized, and Normal.

WorkingDirectory

The fully qualified name of the initial directory for the new process.


進程的啟動:

The following example uses Process to execute Notepad in a maximized window and open a file named C:\Temp\file.txt. After creation, the example calls the Process.WaitForExit method, which blocks the calling thread until a process terminates or a specified time-out expires.


using?System;
using?System.Diagnostics;

public?class?StartProcessExample?{

????
public?static?void?Main?()?{

????????
//?Create?a?ProcessStartInfo?object?and?configure?it?with?the?
????????
//?information?required?to?run?the?new?process.
????????ProcessStartInfo?startInfo?=?new?ProcessStartInfo();

????????startInfo.FileName?
=?"notepad.exe";
????????startInfo.Arguments?
=?"file.txt";
????????startInfo.WorkingDirectory?
=?@"C:\Temp";
????????startInfo.WindowStyle?
=?ProcessWindowStyle.Maximized;
????????startInfo.ErrorDialog?
=?true;

????????
//?Create?a?new?Process?object.
????????using?(Process?process?=?new?Process())?{

????????????
//?Assign?the?ProcessStartInfo?to?the?Process.
????????????process.StartInfo?=?startInfo;

????????????
try?{

????????????????
//?Start?the?new?process.
????????????????process.Start();

????????????????
//?Wait?for?the?new?process?to?terminate?before?exiting.
????????????????Console.WriteLine("Waiting?30?seconds?for?process?to"?+
????????????????????
"?finish.");
????????????????process.WaitForExit(
30000);

????????????}
?catch?(Exception?ex)?{

????????????????Console.WriteLine(
"Could?not?start?process.");
????????????????Console.WriteLine(ex);
????????????}

????????}


????????
//?Wait?to?continue.
????????Console.WriteLine("Main?method?complete.?Press?Enter.");
????????Console.ReadLine();
????}

}


進程終止:
Methods for Obtaining Process References

Method

Description

GetCurrentProcess

Returns a Process object representing the currently active process.

GetProcessById

Returns a Process object representing the process with the specified ID.

GetProcesses

Returns an array of Process objects representing all currently active processes.

GetProcessesByName

Returns an array of Process objects representing all currently active processes with a specified friendly name. The friendly name is the name of the executable excluding file extension or path; for example, notepad or calc.

The following example starts a new instance of Notepad, waits five seconds, and then terminates the Notepad process. The example first tries to terminate the process using CloseMainWindow. If CloseMainWindow returns false, or the Notepad process is still running after CloseMainWindow is called, the example calls Kill and forces the Notepad process to terminate; you can force CloseMainWindow to return false by leaving the File Open dialog box open.

using?System;
using?System.Threading;
using?System.Diagnostics;

public?class?TerminateProcessExample?{

????
public?static?void?Main?()?{

????????
//?Create?a?new?Process?and?run?notepad.exe.
????????using?(Process?process?=?Process.Start("notepad.exe"))?{

????????????
//?Wait?for?5?seconds?and?terminate?the?notepad?process.
????????????Console.WriteLine("Waiting?5?seconds?before?terminating"?+
????????????????
"?notepad.exe.");
????????????Thread.Sleep(
5000);

????????????
//?Terminate?notepad?process.
????????????Console.WriteLine("Terminating?Notepad?with?CloseMainWindow.");

????????????
//?Try?to?send?a?close?message?to?the?main?window.
????????????if?(!process.CloseMainWindow())?{

????????????????
//?Close?message?did?not?get?sent?-?Kill?Notepad.
????????????????Console.WriteLine("CloseMainWindow?returned?false?-?"?+
????????????????????
"?terminating?Notepad?with?Kill.");
????????????????process.Kill();

????????????}
?else?{

????????????????
//?Close?message?sent?successfully;?wait?for?2?seconds
????????????????
//?for?termination?confirmation?before?resorting?to?Kill.
????????????????if?(!process.WaitForExit(2000))?{

????????????????????Console.WriteLine(
"CloseMainWindow?failed?to"?+
????????????????????????
"?terminate?-?terminating?Notepad?with?Kill.");
????????????????????process.Kill();
????????????????}

????????????}

????????}


????????
//?Wait?to?continue.
????????Console.WriteLine("Main?method?complete.?Press?Enter.");
????????Console.ReadLine();
????}

}

posted on 2006-04-20 19:11 夢在天涯 閱讀(2283) 評論(0)  編輯 收藏 引用 所屬分類: C#/.NET

公告

EMail:itech001#126.com

導航

統計

  • 隨筆 - 461
  • 文章 - 4
  • 評論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1811717
  • 排名 - 5

最新評論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              日韩视频免费观看| 免费人成精品欧美精品| 欧美激情久久久久| 国产欧美精品va在线观看| 国内成人精品2018免费看| 在线亚洲自拍| 在线综合视频| 国产精品成人一区二区| 一区二区三区视频免费在线观看| 亚洲第一在线综合在线| 久久久久久午夜| 在线成人中文字幕| 久久一区二区三区国产精品| 久久久97精品| 一区二区三区在线免费视频| 免费观看在线综合| 欧美成人官网二区| 一区二区三区四区五区视频| 夜夜夜久久久| 国产精品国产亚洲精品看不卡15| 亚洲欧美在线免费| 欧美永久精品| 亚洲第一综合天堂另类专| 亚洲福利视频在线| 欧美日韩免费一区二区三区| 91久久久亚洲精品| 亚洲视频在线观看| 国产一级揄自揄精品视频| 久久久久久久久久看片| 美女露胸一区二区三区| 亚洲图片欧美日产| 久久www成人_看片免费不卡| 亚洲免费电影在线观看| 亚洲夜间福利| 国产精品一区二区三区乱码| 欧美一区二区三区四区在线观看 | 欧美风情在线| 亚洲欧美日韩中文播放| 欧美资源在线| 亚洲婷婷综合久久一本伊一区| 亚洲欧美国产精品桃花| 亚洲国产日韩欧美在线图片 | 亚洲一区视频| 久久精品国产久精国产爱| 狠狠色狠狠色综合| 免费成人你懂的| 国产精品r级在线| 牛牛精品成人免费视频| 国产精品jizz在线观看美国| 美女免费视频一区| 国产精品美女久久久久久久 | 国产精品成人免费| 欧美成人首页| 国产欧美另类| 一区二区激情小说| 在线观看欧美日本| 日韩视频中午一区| 伊人久久大香线| 亚洲欧美精品一区| 一区二区三区蜜桃网| 久久免费国产精品1| 欧美一区二区视频97| 欧美搞黄网站| 模特精品在线| 国产亚洲精品v| 亚洲无线视频| 亚洲视频专区在线| 欧美精品性视频| 欧美插天视频在线播放| 欧美午夜视频在线观看| 久久久五月天| 国产噜噜噜噜噜久久久久久久久 | 亚洲一区二区三区在线观看视频| 欧美成人有码| 欧美黄色小视频| 亚洲高清不卡一区| 久久久久国产成人精品亚洲午夜| 久久国产精品99国产| 国产日韩欧美精品综合| 亚洲免费视频一区二区| 午夜精品久久久| 欧美激情亚洲| 亚洲精品欧洲| 亚洲男同1069视频| 国产精品日韩一区二区| 亚洲一区影院| 欧美在线日韩| 国产一区二区0| 久久精品欧美日韩精品| 亚洲欧美在线一区| 美女脱光内衣内裤视频久久网站| 久久综合色播五月| 亚洲黄色天堂| 欧美激情女人20p| 亚洲精品日日夜夜| 亚洲欧美久久久久一区二区三区| 国产精品观看| 久久久久高清| 欧美激情一区二区三区全黄 | 国产亚洲在线| 久久亚洲一区二区| 亚洲国产精品一区| 亚洲一区中文字幕在线观看| 国产精品一区三区| 欧美精品国产一区| 欧美xx视频| 亚洲精选一区二区| 国产精品一卡| 亚洲综合色自拍一区| 美女啪啪无遮挡免费久久网站| 亚洲精品资源美女情侣酒店| 欧美手机在线视频| 久久精品亚洲一区二区| 亚洲国产婷婷香蕉久久久久久99 | 男女激情视频一区| 日韩午夜精品| 午夜精品视频一区| 1204国产成人精品视频| 久久精品国产久精国产思思| 久色成人在线| 亚洲尤物在线| 亚洲国产日韩欧美综合久久 | 亚洲影院污污.| 亚洲国产精品成人| 欧美午夜一区| 亚洲精品美女在线观看播放| 亚洲欧美三级伦理| 91久久久一线二线三线品牌| 国产精品外国| 欧美日韩黄色大片| 欧美在线亚洲一区| 一区二区免费在线播放| 欧美大片在线观看一区二区| 篠田优中文在线播放第一区| 亚洲日本无吗高清不卡| 国产精品日日做人人爱 | 亚洲免费人成在线视频观看| 永久免费视频成人| 国产欧美二区| 欧美日韩免费在线观看| 性欧美1819性猛交| 在线亚洲伦理| 99re66热这里只有精品4| 美女脱光内衣内裤视频久久网站| 西西裸体人体做爰大胆久久久 | 午夜精品久久久久久久白皮肤| 一区二区三区导航| 亚洲精品久久视频| 伊人成年综合电影网| 国产视频不卡| 伊人狠狠色丁香综合尤物| 国产精品久久久久久影视| 欧美午夜不卡在线观看免费 | 欧美日韩中国免费专区在线看| 久久综合九九| 久久另类ts人妖一区二区| 亚洲在线视频一区| 久久精品国产第一区二区三区最新章节| 在线一区视频| 亚洲尤物影院| 欧美亚洲一级| 美日韩在线观看| 免费在线亚洲欧美| 欧美韩日高清| 欧美精品成人| 欧美激情区在线播放| 国产精品美女久久福利网站| 国产精品免费福利| 国产色婷婷国产综合在线理论片a| 国产欧美日韩三区| 亚洲黄色尤物视频| 99re6这里只有精品视频在线观看| 亚洲美女精品久久| 亚洲一区二区三区精品在线| 亚洲一区二区三区免费在线观看| 久久精品国产第一区二区三区最新章节 | 亚洲精品一区中文| 亚洲视频一区二区| 一区二区三区回区在观看免费视频| 亚洲一级一区| 久久精品国产综合| 欧美ed2k| 国产精品久久久久久久久久久久久 | 欧美成人综合| 女女同性女同一区二区三区91| 欧美午夜在线视频| 欧美国产欧美综合| 亚洲最新色图| 欧美亚洲三区| 欧美激情一区二区三区在线视频观看 | 久久久久亚洲综合| 欧美国产日韩一区| 国内成人精品2018免费看| 亚洲蜜桃精久久久久久久| 午夜激情亚洲| 欧美xxx在线观看| 亚洲精品字幕| 看片网站欧美日韩| 国产精品家庭影院| 亚洲第一中文字幕|