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

C++ Programmer's Cookbook

{C++ 基礎(chǔ)} {C++ 高級(jí)} {C#界面,C++核心算法} {設(shè)計(jì)模式} {C#基礎(chǔ)}

進(jìn)程 Process的使用

1 Process?
? 簡單實(shí)例:

// ?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.


進(jìn)程的啟動(dòng):

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

}


進(jìn)程終止:
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) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C#/.NET

公告

EMail:itech001#126.com

導(dǎo)航

統(tǒng)計(jì)

  • 隨筆 - 461
  • 文章 - 4
  • 評(píng)論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1818421
  • 排名 - 5

最新評(píng)論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
              91久久精品国产91久久性色tv| 国产精品久久久久婷婷| 欧美黑人一区二区三区| 亚洲福利视频一区| 欧美电影免费观看大全| 亚洲人成啪啪网站| 亚洲欧美久久久| 国产视频一区在线观看| 久久在线精品| 亚洲精品久久嫩草网站秘色| 亚洲一区亚洲| 国产欧美日本一区视频| 久久亚洲春色中文字幕久久久| 亚洲国产成人精品女人久久久 | 亚欧成人在线| 久久综合国产精品| 亚洲精品在线看| 国产精品福利在线| 久久国产色av| 亚洲精选成人| 久久九九国产| 日韩亚洲欧美在线观看| 国产精品影片在线观看| 久久婷婷蜜乳一本欲蜜臀| 亚洲片在线观看| 久久精品国产在热久久 | 欧美成人精品激情在线观看| 亚洲精品一区二区三区99| 午夜精品久久久久久久99樱桃 | 欧美一区二区高清| 亚洲国产高清视频| 国产精品扒开腿做爽爽爽视频| 久久国产精彩视频| 99在线|亚洲一区二区| 久热精品视频在线观看一区| 中文在线资源观看网站视频免费不卡| 国产乱码精品1区2区3区| 欧美高清在线| 欧美一区二区黄| 99精品视频免费观看视频| 蜜臀va亚洲va欧美va天堂| 亚洲一区二区成人| 亚洲国产精品t66y| 国产视频在线观看一区二区| 欧美日韩精品一区二区在线播放 | 美女久久一区| 香蕉久久精品日日躁夜夜躁| 亚洲精品视频在线观看网站| 乱人伦精品视频在线观看| 亚洲免费网址| 夜夜嗨av一区二区三区四季av| 一区三区视频| 国产女人精品视频| 国产精品成人免费精品自在线观看| 久久久久欧美精品| 欧美一区二区三区久久精品| 一本一本a久久| 亚洲日本成人女熟在线观看| 欧美国产在线视频| 久久综合色播五月| 久久精品水蜜桃av综合天堂| 亚洲欧美日韩国产中文在线| 亚洲视频在线二区| aa亚洲婷婷| 99国产精品| 亚洲久久在线| 亚洲精品视频在线观看免费| 亚洲狠狠丁香婷婷综合久久久| 韩日欧美一区二区三区| 国产在线拍揄自揄视频不卡99 | 日韩小视频在线观看专区| 91久久夜色精品国产九色| 黄色成人在线网站| 一区二区三区亚洲| 一区二区亚洲精品国产| 国内揄拍国内精品久久| 国内精品伊人久久久久av一坑| 国产精品中文在线| 国产精品一区久久| 国产美女精品视频免费观看| 国产麻豆视频精品| 国产欧美精品久久| 国产在线一区二区三区四区 | 老巨人导航500精品| 久久久久亚洲综合| 麻豆亚洲精品| 欧美大片一区二区三区| 欧美极品aⅴ影院| 欧美激情在线观看| 欧美三日本三级少妇三2023| 欧美三级午夜理伦三级中视频| 欧美日韩在线影院| 国产精品一区二区三区久久| 国产模特精品视频久久久久| 国产综合色产| 亚洲国产精品一区二区第四页av| 亚洲欧洲综合另类| 在线视频亚洲| 欧美在线视频一区二区| 蜜臀av在线播放一区二区三区| 亚洲高清在线| 一区二区三区.www| 久久成人免费电影| 欧美成人中文字幕| 国产精品毛片a∨一区二区三区| 国产欧美在线看| 亚洲国产成人不卡| 亚洲夜晚福利在线观看| 久久精品色图| 亚洲激情黄色| 亚洲欧美日本伦理| 麻豆成人在线| 国产精品久久久久久久久久妞妞| 激情91久久| 一本久道综合久久精品| 欧美一区二区在线观看| 欧美刺激午夜性久久久久久久| 日韩网站在线| 欧美在线一级va免费观看| 欧美激情女人20p| 国产视频在线观看一区二区三区| 亚洲国产经典视频| 亚洲欧美日韩精品| 亚洲第一黄色| 欧美一级欧美一级在线播放| 欧美黑人在线观看| 韩国一区二区三区在线观看| 在线一区二区日韩| 免费视频一区| 亚洲欧美日韩视频一区| 免费短视频成人日韩| 国产欧美一区二区三区在线老狼| 亚洲精品护士| 久久久噜噜噜久久中文字免| 99在线|亚洲一区二区| 看片网站欧美日韩| 国产精品中文字幕在线观看| 日韩一级免费观看| 玖玖综合伊人| 午夜精品99久久免费| 欧美日韩免费观看一区二区三区| 一区二区在线看| 久久国产精品99精品国产| 99精品99久久久久久宅男| 欧美成人一区二区三区片免费| 国产亚洲精品一区二555| 亚洲一区二区三区四区视频 | 日韩天天综合| 欧美成人国产一区二区| 国产一区二区你懂的| 亚洲免费视频网站| 日韩一级精品| 欧美精品少妇一区二区三区| 亚洲韩国日本中文字幕| 另类天堂av| 久久成年人视频| 黄色av日韩| 久久亚洲免费| 欧美在线观看视频| 国产深夜精品福利| 欧美在线免费视屏| 亚洲欧美日韩系列| 国产日韩欧美亚洲| 久久爱91午夜羞羞| 香蕉久久a毛片| 国产拍揄自揄精品视频麻豆| 性欧美暴力猛交另类hd| 亚洲一区二区免费在线| 国产精品海角社区在线观看| 亚洲视频日本| 在线一区观看| 国产精品日韩久久久久| 欧美亚洲免费电影| 午夜国产精品视频免费体验区| 国产精品一区免费观看| 久久成人免费| 久久精品欧美| 在线成人免费观看| 欧美激情综合| 欧美日本网站| 午夜精品久久一牛影视| 亚洲欧美日韩一区在线观看| 国产在线国偷精品产拍免费yy| 久久这里有精品视频| 麻豆精品在线视频| 亚洲视频在线观看| 亚洲一级二级在线| 狠狠做深爱婷婷久久综合一区 | 亚洲国产成人av在线| 欧美日韩亚洲三区| 欧美一区二区三区在| 久久久久9999亚洲精品| 亚洲全部视频| 在线一区日本视频| 国产在线欧美日韩| 亚洲人成高清| 国产裸体写真av一区二区| 欧美二区在线播放| 国产精品国产三级国产a| 欧美在线综合|