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

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>
              亚洲国产一二三| 亚洲国产欧美一区二区三区丁香婷| 亚洲电影视频在线| 久久男女视频| 在线看一区二区| 免费永久网站黄欧美| 久久国产精品久久w女人spa| 国产一区视频观看| 免费短视频成人日韩| 久久久久久婷| 亚洲欧洲日本国产| 亚洲精品乱码久久久久久日本蜜臀| 欧美成人69av| 国产精品99久久久久久宅男| 一区二区三欧美| 国产精品五月天| 久久久久一区二区| 欧美aa在线视频| 一个色综合导航| 午夜精品久久久久久久蜜桃app | 亚洲色图在线视频| 欧美天天视频| 欧美综合激情网| 久久综合电影| 亚洲午夜精品一区二区| 羞羞色国产精品| 亚洲国产精品成人精品| 日韩香蕉视频| 国产在线乱码一区二区三区| 亚洲第一区在线观看| 欧美三级午夜理伦三级中文幕 | 亚洲日本乱码在线观看| 亚洲精选中文字幕| 国产亚洲第一区| 亚洲激情另类| 国产日产高清欧美一区二区三区| 美日韩精品视频| 欧美日韩在线综合| 免费久久99精品国产自| 欧美三日本三级少妇三99 | 在线成人免费观看| 一区二区免费在线视频| 激情综合色丁香一区二区| 亚洲欧洲日韩在线| 狠狠色狠狠色综合日日小说| 亚洲精品一区二区三区99| 国产一区二区三区在线免费观看| 亚洲欧洲日产国产网站| 韩国女主播一区| 一本不卡影院| 一本色道久久88精品综合| 久久精品国产亚洲a| 亚洲在线成人精品| 欧美连裤袜在线视频| 久久久精品一区| 国产精品欧美风情| 99在线精品视频在线观看| 91久久精品久久国产性色也91| 性欧美暴力猛交另类hd| 亚洲一区二区三区三| 欧美另类69精品久久久久9999| 牛牛精品成人免费视频| 国产亚洲午夜高清国产拍精品| 一区二区三区毛片| 中文日韩电影网站| 欧美日韩精品免费观看| 亚洲韩国精品一区| 亚洲黄色在线看| 乱码第一页成人| 免费不卡亚洲欧美| 樱桃视频在线观看一区| 欧美一区二区三区在线观看| 欧美亚洲视频一区二区| 国产精品美女久久久久久免费 | 性欧美8khd高清极品| 国产精品久久久久7777婷婷| 亚洲视频一二| 亚洲欧美偷拍卡通变态| 国产精品乱码人人做人人爱| 一区二区日韩| 欧美影院成年免费版| 国产日本精品| 久久精品中文| 欧美大成色www永久网站婷| 亚洲国产午夜| 欧美精品久久久久a| 99在线|亚洲一区二区| 亚洲一区二区三区免费观看| 国产精品美女主播在线观看纯欲| 亚洲午夜av在线| 久久精品国产亚洲一区二区| 黄色成人在线观看| 欧美刺激午夜性久久久久久久| 亚洲精品孕妇| 欧美亚洲综合另类| 国内视频一区| 欧美黄色免费| 亚洲一区高清| 老司机久久99久久精品播放免费| 亚洲电影下载| 欧美午夜理伦三级在线观看| 亚洲一区二区三区精品在线| 久久精品中文字幕一区| 亚洲国产一二三| 欧美亚洲成人网| 欧美一区二区精品| 亚洲第一主播视频| 亚洲欧美久久久| 极品av少妇一区二区| 欧美日韩大片一区二区三区| 亚洲欧美国产一区二区三区| 你懂的成人av| 亚洲欧美日本视频在线观看| 一区在线播放视频| 国产精品va在线播放| 久久国产精品亚洲va麻豆| 最新成人在线| 玖玖综合伊人| 亚洲专区在线| 亚洲欧洲日本在线| 国内成人精品2018免费看| 欧美区一区二| 老牛影视一区二区三区| 午夜精品电影| 99国产精品一区| 欧美国产第一页| 久久久91精品| 先锋影音网一区二区| 99国产精品久久久久老师| 国内精品一区二区| 国产精品裸体一区二区三区| 欧美精品久久久久久久久久| 久久久免费精品视频| 亚洲欧美日韩综合| 在线午夜精品自拍| 亚洲精品一级| 亚洲激情在线观看视频免费| 久久一区二区视频| 久久久久久久久久久一区| 午夜精品国产精品大乳美女| 亚洲图片欧洲图片av| 9色porny自拍视频一区二区| 亚洲激情黄色| 亚洲韩日在线| 最新日韩av| 亚洲欧洲一二三| 亚洲欧洲精品一区二区精品久久久| 国内精品久久久久久久影视麻豆 | 国产精品日韩在线播放| 欧美日韩亚洲一区二区| 欧美日本二区| 欧美区国产区| 欧美视频日韩视频| 欧美色视频在线| 欧美日韩一二三四五区| 欧美日韩国产成人精品| 欧美日韩精品免费| 欧美体内谢she精2性欧美| 国产精品videosex极品| 国产精品欧美日韩| 国产午夜精品久久久| 黄色综合网站| 亚洲区国产区| 一区二区三区精品国产| 中文亚洲视频在线| 欧美一区二区三区成人| 久久久久久欧美| 欧美成人精品福利| 亚洲欧洲一区二区在线观看| 99精品视频免费| 亚洲欧美日韩成人高清在线一区| 亚洲一区欧美二区| 久久精品人人| 欧美激情第二页| 国产精品成人观看视频免费| 国产欧美精品日韩精品| 好吊色欧美一区二区三区视频| 亚洲国产福利在线| 这里只有精品视频在线| 欧美一级黄色录像| 欧美国产视频日韩| 制服丝袜激情欧洲亚洲| 久久精品欧美日韩| 欧美精品一区二区视频| 国产噜噜噜噜噜久久久久久久久| 在线日韩中文| 亚洲一区激情| 久久综合久久综合这里只有精品| 亚洲国产第一| 午夜伦欧美伦电影理论片| 麻豆久久精品| 国产欧美日韩视频一区二区三区| 亚洲电影视频在线| 午夜影院日韩| 亚洲国产专区| 欧美一区亚洲| 欧美视频精品在线观看| 亚洲国产成人午夜在线一区| 亚洲一区二区在线播放| 欧美激情1区2区3区|