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

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>
              亚洲视频免费在线| 一本色道久久88综合亚洲精品ⅰ| 欧美一级视频免费在线观看| 99精品视频免费全部在线| 欧美日韩伦理在线免费| 亚洲系列中文字幕| 性久久久久久久久| 精品成人在线| 亚洲第一精品夜夜躁人人爽| 美女久久一区| 亚洲一区视频| 久久精品99无色码中文字幕| 在线观看欧美视频| 亚洲精品日韩欧美| 国产一区二区三区丝袜 | 国产欧美日韩精品一区| 久久久另类综合| 欧美啪啪一区| 久久国产欧美| 欧美日韩国产综合视频在线观看 | 激情亚洲网站| 99re热这里只有精品免费视频| 欧美午夜美女看片| 老牛国产精品一区的观看方式| 欧美精品 国产精品| 亚洲欧美日本国产专区一区| 久久久国产精品一区| 亚洲最黄网站| 久久久夜精品| 亚洲欧美日韩天堂| 欧美国产欧美亚洲国产日韩mv天天看完整 | 国产精品视频第一区| 久久综合狠狠综合久久综合88| 欧美aⅴ99久久黑人专区| 亚洲伊人一本大道中文字幕| 久久久人人人| 久久gogo国模裸体人体| 欧美激情综合色综合啪啪| 性欧美1819性猛交| 欧美日韩精品欧美日韩精品一| 久久视频一区二区| 国产精品自拍一区| 99精品国产99久久久久久福利| 在线看国产一区| 午夜精品三级视频福利| 亚洲小少妇裸体bbw| 免费成人小视频| 久久亚洲一区| 国内一区二区三区| 亚洲欧美日韩综合| 性娇小13――14欧美| 欧美香蕉大胸在线视频观看| 亚洲国产精品久久久久婷婷老年 | 一区二区三区在线观看欧美| 亚洲一区中文| 亚洲欧美视频在线观看| 欧美日韩在线电影| 一个色综合av| 亚洲图片自拍偷拍| 欧美日韩免费在线| 99视频在线观看一区三区| 亚洲精品免费电影| 欧美高清不卡| 最新亚洲一区| 一区二区三区 在线观看视频| 欧美高清视频| 亚洲精品影视| 宅男精品导航| 欧美视频在线播放| 亚洲一级在线| 久久精品二区| 一区免费视频| 老司机精品导航| 亚洲国产mv| 亚洲一区二区三区乱码aⅴ| 欧美午夜宅男影院| 欧美一区二区视频网站| 久久综合给合久久狠狠狠97色69| 伊人天天综合| 欧美精品 日韩| 一区二区三区三区在线| 午夜精品视频在线观看| 国产欧美一区二区精品婷婷| 欧美一区二区免费视频| 老司机精品导航| 99在线精品视频在线观看| 欧美手机在线| 欧美在线三区| 亚洲精品国精品久久99热一| 亚洲综合精品| 在线观看日韩欧美| 欧美午夜理伦三级在线观看| 欧美一区二区在线免费播放| 欧美激情aⅴ一区二区三区| 日韩午夜精品视频| 国产欧美日韩一区二区三区在线 | 欧美高清一区二区| 宅男噜噜噜66一区二区| 久久久美女艺术照精彩视频福利播放 | 欧美午夜精品久久久久久久 | 亚洲一区二三| 欧美www在线| 亚洲免费伊人电影在线观看av| 国产日韩精品一区二区三区 | 久热成人在线视频| 夜夜精品视频一区二区| 麻豆精品视频在线观看视频| 一本色道久久综合亚洲91| 国产日韩欧美三区| 国产精品v欧美精品v日韩| 久久久久久久999精品视频| 日韩亚洲欧美一区| 亚洲国产高清在线观看视频| 欧美主播一区二区三区| 9l国产精品久久久久麻豆| 国产真实精品久久二三区| 欧美日韩另类视频| 免费观看成人鲁鲁鲁鲁鲁视频| 午夜在线精品偷拍| 一本不卡影院| 亚洲人成在线播放| 美女久久一区| 久久精品人人做人人爽电影蜜月| 亚洲天堂av在线免费| 亚洲国产一区二区在线| 国产综合激情| 国产精品亚洲一区二区三区在线| 欧美日韩国产在线看| 欧美激情aⅴ一区二区三区| 久久人体大胆视频| 久久成人在线| 欧美一区二区性| 午夜久久久久久久久久一区二区| 日韩香蕉视频| 亚洲精品国产欧美| 亚洲精品欧美激情| 亚洲美洲欧洲综合国产一区| 亚洲高清激情| 最新中文字幕一区二区三区| 欧美岛国激情| 欧美jizz19hd性欧美| 美女国产一区| 免费国产一区二区| 欧美1级日本1级| 亚洲电影在线免费观看| 欧美激情精品久久久六区热门| 欧美高清视频一区二区| 欧美激情精品久久久六区热门 | 日韩视频一区| 99视频精品在线| 亚洲女人小视频在线观看| 亚洲一区二区三区乱码aⅴ蜜桃女| 亚洲午夜精品久久久久久app| 亚洲永久在线观看| 久久国产精品第一页| 久久综合久久综合久久| 欧美人与禽猛交乱配| 欧美日韩日日骚| 国产欧美日韩高清| 在线精品亚洲| 亚洲视频在线观看| 久久av在线看| 亚洲第一天堂av| 一区二区精品| 久久精品视频一| 免费在线观看精品| 欧美午夜精品久久久久久久| 国产精品一区=区| 亚洲国产成人精品视频| 一本色道久久88精品综合| 香蕉久久a毛片| 欧美激情1区2区3区| 中文久久乱码一区二区| 久久久99爱| 欧美日韩国产综合视频在线观看中文 | 欧美午夜视频网站| 韩国av一区| 一区二区三区四区蜜桃| 久久福利一区| 亚洲欧洲一区二区在线播放 | 亚洲免费播放| 久久香蕉国产线看观看av| 欧美理论电影在线观看| 国产午夜精品久久久久久久| 亚洲人成人99网站| 久久经典综合| 亚洲毛片在线免费观看| 久久久无码精品亚洲日韩按摩| 欧美日韩精品一区二区| 永久域名在线精品| 午夜一区不卡| 亚洲精品影视| 美女亚洲精品| 精品不卡视频| 性欧美1819性猛交| 99精品黄色片免费大全| 久久综合九色九九| 国产主播喷水一区二区| 在线亚洲自拍| 亚洲精品久久久久久一区二区|