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

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

搜索

  •  

積分與排名

  • 積分 - 1815364
  • 排名 - 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>
              欧美在线一级视频| 午夜一区在线| 国产欧美日韩另类一区| 欧美先锋影音| 国产精品热久久久久夜色精品三区| 欧美日韩国产在线看| 欧美久久久久免费| 国产精品扒开腿做爽爽爽视频 | 日韩视频专区| 一本不卡影院| 亚洲综合色丁香婷婷六月图片| 性久久久久久久久久久久| 久久久精品性| 欧美三级视频在线| 国产手机视频一区二区| 尤物九九久久国产精品的特点| 亚洲精品久久久蜜桃| 亚洲欧美精品| 欧美激情精品久久久久久蜜臀| av不卡在线| 久久精品麻豆| 国产精品红桃| 亚洲电影免费| 欧美一区久久| 亚洲精品乱码久久久久久蜜桃麻豆 | 亚欧美中日韩视频| 久久夜色精品| 夜夜嗨av一区二区三区中文字幕| 久久精品视频在线看| 欧美日韩亚洲一区二区三区在线| 国产在线日韩| 亚洲欧美一区二区三区久久| 亚洲丰满在线| 久久精品欧美日韩| 国产精品久久久久毛片大屁完整版| 在线精品视频一区二区| 亚洲国产精彩中文乱码av在线播放| 国产精品久久国产精麻豆99网站| 国产一区二区三区在线观看免费视频 | 一本色道久久综合亚洲精品不 | 久久精品国产清高在天天线| 欧美日韩视频在线第一区| 亚洲第一综合天堂另类专| 久久国产主播| 亚洲性线免费观看视频成熟| 欧美精品亚洲一区二区在线播放| 精品不卡一区二区三区| 香蕉久久夜色精品国产| 亚洲精品国精品久久99热| 巨乳诱惑日韩免费av| 黄网站免费久久| 久久久天天操| 欧美在线一区二区| 黑人巨大精品欧美一区二区| 久久av资源网| 欧美一区亚洲| 国产综合久久久久久鬼色| 久久精品国产久精国产爱| 亚洲欧美日韩第一区| 国产精品一区二区久久| 小辣椒精品导航| 亚洲欧美国产精品专区久久| 国产精品第一区| 亚洲欧美日韩区| 午夜精品久久久久久99热| 国产午夜亚洲精品不卡| 久久伊人一区二区| 免费久久99精品国产自在现线| 亚洲高清在线播放| 亚洲国内自拍| 国产精品wwwwww| 欧美有码在线视频| 久久se精品一区精品二区| 亚洲高清自拍| 亚洲免费av片| 国产人成精品一区二区三| 久久婷婷av| 美日韩在线观看| 中文在线资源观看网站视频免费不卡| 99精品99久久久久久宅男| 国产精品入口| 玖玖综合伊人| 欧美日韩大陆在线| 久久高清国产| 欧美jjzz| 亚洲欧美三级伦理| 久久久久99| 一二三四社区欧美黄| 久久久久久久久伊人| 欧美在线视频播放| 亚洲久久一区| 亚洲欧美久久| 亚洲国产欧美久久| 亚洲伊人第一页| 在线观看三级视频欧美| 99国产精品久久久久久久| 国产精品久久久久久久一区探花 | 亚洲综合精品四区| 欧美中文字幕视频| 一本色道久久综合狠狠躁的推荐| 亚洲免费在线视频| 亚洲另类在线视频| 欧美专区在线观看一区| 9国产精品视频| 久久久夜色精品亚洲| 亚洲一区二区三区免费在线观看 | 久久精品夜色噜噜亚洲a∨ | 羞羞漫画18久久大片| 欧美成人一区二区三区| 久久精品国产一区二区三区| 欧美国产综合一区二区| 久久视频国产精品免费视频在线| 欧美日韩在线观看视频| 欧美国产一区视频在线观看| 国产一区二区三区免费不卡| 一区二区三区高清不卡| 亚洲精品一区久久久久久| 久久久国产亚洲精品| 欧美怡红院视频| 国产精品久久久久久超碰| 亚洲精品视频免费观看| 亚洲日本欧美天堂| 男女视频一区二区| 欧美国产日韩一区二区在线观看 | 亚洲一区二区三区视频| 亚洲精品久久久久久久久久久久| 欧美制服丝袜| 久久精品伊人| 国内精品久久久久影院 日本资源| 亚洲一区二区三区涩| 午夜精品久久久久99热蜜桃导演| 欧美日本一道本| 亚洲精品麻豆| 亚洲视频精选在线| 欧美色精品天天在线观看视频| 亚洲高清不卡| 日韩午夜av| 欧美日韩亚洲高清一区二区| 日韩午夜三级在线| 亚洲在线第一页| 国产精品一区二区欧美| 一本色道久久88亚洲综合88| 亚洲一区在线免费| 国产精品视频大全| 欧美一区二区大片| 久久久久久网址| 久久婷婷国产麻豆91天堂| 久久精品中文字幕一区二区三区 | 黑人中文字幕一区二区三区 | 欧美在线观看日本一区| 久久久久久97三级| 亚洲国产精品久久久久婷婷老年| 欧美顶级大胆免费视频| 99国产精品99久久久久久| 销魂美女一区二区三区视频在线| 国产小视频国产精品| 老鸭窝毛片一区二区三区| 91久久极品少妇xxxxⅹ软件| 亚洲一区二区三区免费在线观看| 国产婷婷色一区二区三区在线| 久久婷婷一区| 99精品免费视频| 欧美专区福利在线| 亚洲精品国产品国语在线app | 久久精品久久99精品久久| 欧美国产一区二区在线观看| 一区二区福利| 国产一级揄自揄精品视频| 欧美.日韩.国产.一区.二区| 亚洲美女在线国产| 久久精品视频免费| 99国产精品国产精品久久| 国产欧美综合在线| 欧美激情一区二区久久久| 亚洲欧美日产图| 亚洲激情视频在线播放| 久久成人免费网| 一区二区三区毛片| 影音先锋亚洲一区| 国产精品日韩欧美| 欧美精品在欧美一区二区少妇| 欧美在线电影| 亚洲视频中文| 91久久久久| 美乳少妇欧美精品| 欧美一区二区日韩| 在线视频日韩精品| 亚洲欧洲视频| 一区免费在线| 国产精品视频你懂的| 欧美激情精品久久久久久黑人| 亚洲欧美一区二区三区极速播放 | 亚洲欧美国产不卡| 亚洲精品护士| 黑人极品videos精品欧美裸| 国产精品亚洲成人| 欧美午夜电影完整版| 欧美精品在线观看91| 欧美成人乱码一区二区三区| 久久精品国产2020观看福利|