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

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 夢在天涯 閱讀(2285) 評論(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

搜索

  •  

積分與排名

  • 積分 - 1818525
  • 排名 - 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>
              老司机免费视频一区二区| 欧美freesex交免费视频| 欧美极品在线视频| 亚洲人精品午夜| 欧美国产日韩a欧美在线观看| 久久久久久国产精品mv| 一区二区三区在线观看国产| 国产一区二区高清视频| 久久人人看视频| 久热精品在线| 一区二区欧美日韩视频| 亚洲一区二区免费看| 国产九九精品视频| 乱中年女人伦av一区二区| 久久综合久久综合这里只有精品| 久久久久久一区| 亚洲欧洲三级| 亚洲视频二区| 在线成人av网站| 亚洲精品中文字幕女同| 国产精品视频精品视频| 久久久久一区二区三区| 欧美成人精品激情在线观看| 免费不卡中文字幕视频| 亚洲在线观看视频| 国产一区视频在线观看免费| 美女露胸一区二区三区| 欧美日本一道本| 欧美在线免费看| 欧美成人有码| 国产精品久久久久一区二区三区共 | 欧美日本亚洲韩国国产| 国产精品久久一区二区三区| 久久国产视频网| 欧美久久电影| 久久久欧美一区二区| 欧美日韩成人一区二区三区| 久久久久久久久久码影片| 欧美人与禽猛交乱配| 久久综合九色九九| 国产精品美女久久久久久久| 激情综合网址| 亚洲一区二区三区中文字幕在线 | 欧美成人激情视频| 久久激情综合网| 欧美日韩亚洲综合在线| 亚洲人成在线播放网站岛国| 亚洲欧美日本另类| 一区二区三区高清不卡| 久久午夜激情| 久久国产精彩视频| 国产精品久久久久影院色老大| 欧美激情免费在线| 激情成人av在线| 亚洲欧美日韩中文播放| 中日韩午夜理伦电影免费| 亚洲国产欧美在线人成| 国产日韩欧美麻豆| 一区二区三区欧美在线| 洋洋av久久久久久久一区| 久久综合国产精品| 蜜臀99久久精品久久久久久软件| 国产欧美69| 亚洲免费在线电影| 午夜欧美不卡精品aaaaa| 欧美麻豆久久久久久中文| 亚洲国产成人久久综合| 亚洲动漫精品| 免费人成精品欧美精品| 欧美成人免费小视频| 久久gogo国模裸体人体| 欧美在线亚洲综合一区| 国产婷婷成人久久av免费高清 | 亚洲免费一在线| 欧美日韩日日夜夜| 夜夜精品视频| 欧美一区国产在线| 国产一区二区成人| 久久精品一区二区三区中文字幕| 国产欧美一区二区精品忘忧草 | 日韩午夜免费| 亚洲一区二区三区四区视频| 欧美少妇一区二区| 亚洲午夜免费视频| 国产精品视频999| 久久精品国产久精国产一老狼| 久久综合成人精品亚洲另类欧美 | 欧美激情在线播放| 一本在线高清不卡dvd| 欧美一级视频免费在线观看| 玖玖玖国产精品| 欧美激情网友自拍| 一区二区三区高清在线 | 美日韩精品免费| 亚洲国产婷婷香蕉久久久久久99| 亚洲视频国产视频| 国产美女搞久久| 麻豆国产va免费精品高清在线| 亚洲国产日韩欧美综合久久| 亚洲一级网站| 在线欧美不卡| 国产精品大片免费观看| 久久精品av麻豆的观看方式| 亚洲成色777777在线观看影院| 国模私拍一区二区三区| 欧美成人dvd在线视频| 一区二区日韩免费看| 久久综合狠狠综合久久综青草| 亚洲美女电影在线| 国产婷婷精品| 欧美精品久久一区| 欧美在线一区二区| 一本色道久久加勒比88综合| 久久亚洲综合色| 亚洲欧美日韩一区二区三区在线| 激情六月婷婷久久| 欧美亚洲成人免费| 欧美96在线丨欧| 久久精品99国产精品酒店日本| 日韩亚洲欧美成人一区| 国产一区二区电影在线观看| 欧美日韩在线播放| 美女脱光内衣内裤视频久久影院 | 亚洲欧美激情诱惑| 亚洲精品一区二区三| 免费视频最近日韩| 欧美专区日韩专区| 正在播放亚洲一区| 最新中文字幕一区二区三区| 久久天天躁狠狠躁夜夜av| 亚洲在线日韩| 99视频精品| 亚洲欧洲午夜| 亚洲国产黄色片| 黄色资源网久久资源365| 国产日韩精品视频一区二区三区| 欧美日韩在线电影| 欧美日本高清一区| 欧美成人综合网站| 欧美jizz19hd性欧美| 免费观看成人鲁鲁鲁鲁鲁视频| 久久av资源网| 久久精品综合| 久久久精品一区二区三区| 亚欧成人在线| 亚洲国产成人tv| 欧美激情第五页| 欧美激情中文字幕一区二区| 久久亚洲精品视频| 久久这里有精品15一区二区三区| 欧美一区免费| 久久久久国产免费免费| 久久国产视频网站| 久久久久久久久久久久久久一区 | 亚洲精品乱码久久久久久久久| 宅男噜噜噜66一区二区66| 日韩视频一区二区三区在线播放免费观看| 在线不卡中文字幕播放| 亚洲丶国产丶欧美一区二区三区| 精品不卡一区| 亚洲国产毛片完整版| 亚洲精品一区二区三区在线观看| 亚洲精品久久久蜜桃| av成人免费| 欧美伊人久久大香线蕉综合69| 欧美一站二站| 欧美成人精品h版在线观看| 亚洲电影免费在线| 一区二区三区精品国产| 亚洲欧美综合| 免费成人在线视频网站| 欧美日韩不卡合集视频| 国产精品一区二区在线观看| 韩国成人福利片在线播放| 亚洲激情偷拍| 亚洲综合999| 久久综合给合久久狠狠色 | 亚洲中字在线| 猛干欧美女孩| 一本色道久久综合亚洲精品小说 | 亚洲国产视频直播| 在线视频精品一| 久久精品一区二区国产| 亚洲激情一区二区| 亚洲欧美一级二级三级| 免费不卡视频| 国产精品一区二区你懂得| 亚洲国产日韩在线一区模特| 亚洲欧美国产一区二区三区| 久久精品人人做人人爽电影蜜月| 欧美高清视频一区二区| 亚洲一区在线播放| 欧美激情1区2区3区| 国产农村妇女毛片精品久久麻豆 | 亚洲一区二区欧美| 精品成人在线观看| 亚洲一区二区高清| 欧美福利视频| 欧美伊人久久大香线蕉综合69| 欧美日韩一二三四五区|