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

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>
              国产亚洲欧美日韩一区二区| 久久精彩免费视频| 欧美人与禽性xxxxx杂性| 亚洲精品久久久久久一区二区| 亚洲区第一页| 国产精品va| 欧美专区在线播放| 欧美sm极限捆绑bd| 一区二区三区欧美成人| 国产精品女主播| 久久精品一级爱片| 亚洲欧洲一级| 欧美中文字幕久久| 亚洲日本理论电影| 亚洲永久免费视频| 亚洲电影在线观看| 亚洲主播在线播放| 亚洲成在线观看| 欧美色欧美亚洲另类二区| 亚欧成人在线| 亚洲精品女人| 午夜精彩视频在线观看不卡 | 亚洲日本中文字幕| 亚洲一区二区三区视频播放| 国产综合色产| 欧美日韩精品系列| 久久久噜噜噜久久| 亚洲视频中文| 亚洲国产精品成人精品| 欧美在线播放视频| 99精品福利视频| 国一区二区在线观看| 欧美视频日韩视频| 欧美不卡视频| 午夜精品一区二区三区四区| 最近看过的日韩成人| 久久久久久亚洲精品杨幂换脸| 一本色道久久综合| 亚洲国产精品久久人人爱蜜臀 | 在线视频欧美精品| 在线观看精品视频| 国产日本欧美一区二区| 欧美日韩视频不卡| 美女亚洲精品| 久久精品视频免费播放| 亚洲男人的天堂在线aⅴ视频| 亚洲欧洲日本在线| 欧美成人精品影院| 久久久久久久久久久一区 | 91久久久国产精品| 欧美成人网在线| 久久色在线播放| 久久精品久久99精品久久| 亚洲欧美日韩视频二区| 一区二区国产在线观看| 亚洲三级影院| 亚洲人午夜精品免费| 一色屋精品亚洲香蕉网站| 国产专区欧美精品| 国产日韩综合一区二区性色av| 国产精品久久久久av| 欧美视频日韩视频| 欧美性猛交99久久久久99按摩| 欧美伦理91i| 欧美破处大片在线视频| 欧美成人一品| 欧美高清视频在线观看| 欧美成人福利视频| 欧美精彩视频一区二区三区| 欧美成人一区二区在线| 欧美国产精品人人做人人爱| 亚洲精品无人区| 欧美一区精品| 欧美伊人影院| 久久九九有精品国产23| 久久精品国产91精品亚洲| 性做久久久久久久久| 欧美一级视频精品观看| 欧美一区二区视频免费观看| 西西人体一区二区| 午夜久久久久久久久久一区二区| 亚洲在线观看免费| 欧美在线国产| 久久久之久亚州精品露出| 久久久久久一区二区| 蜜臀99久久精品久久久久久软件| 欧美va亚洲va日韩∨a综合色| 欧美精品情趣视频| 欧美性猛交xxxx乱大交退制版| 国产精品www网站| 国产亚洲欧美一区二区三区| 狠狠色香婷婷久久亚洲精品| 亚洲福利视频一区| 9人人澡人人爽人人精品| 亚洲摸下面视频| 久久亚洲高清| 91久久国产综合久久91精品网站| 夜夜嗨av一区二区三区免费区 | 亚洲欧美成人| 久久亚洲美女| 欧美色图一区二区三区| 国模叶桐国产精品一区| 亚洲精品国久久99热| 亚洲一区日韩在线| 久久亚洲私人国产精品va| 欧美激情小视频| 亚洲一级一区| 另类综合日韩欧美亚洲| 欧美日韩在线高清| 国内精品伊人久久久久av一坑| 亚洲美女免费视频| 久久国产免费看| 亚洲精品乱码久久久久| 欧美一级二区| 欧美区二区三区| 国语自产在线不卡| 亚洲丝袜av一区| 欧美freesex交免费视频| 宅男噜噜噜66国产日韩在线观看| 久久精品道一区二区三区| 欧美区在线观看| 红桃视频一区| 欧美一区二区黄色| 99精品视频一区二区三区| 久久久777| 国产精品亚洲综合色区韩国| 最新国产精品拍自在线播放| 欧美在线观看你懂的| 亚洲精品久久久一区二区三区| 久久久久**毛片大全| 国产精品a久久久久| 亚洲国产欧美日韩| 久久国产福利国产秒拍| 99国产精品久久| 欧美激情第10页| 影音先锋久久久| 久久精品毛片| 亚洲中无吗在线| 欧美日韩综合视频网址| 亚洲精品老司机| 蘑菇福利视频一区播放| 免费国产一区二区| 欧美日韩一区二区欧美激情| 亚洲成色精品| 美女精品网站| 欧美亚洲综合在线| 国产精品一页| 亚洲欧美一区二区原创| 999在线观看精品免费不卡网站| 欧美xxx成人| 亚洲精华国产欧美| 欧美成人精品在线| 裸体女人亚洲精品一区| 一区二区三区在线视频观看| 久久精品国产精品亚洲综合 | 欧美精品在线免费观看| 亚洲国产精品成人| 卡一卡二国产精品| 久久久av网站| 在线免费高清一区二区三区| 久久久青草青青国产亚洲免观| 先锋影音一区二区三区| 国产免费成人av| 久久精品30| 久久国产色av| 影音先锋在线一区| 欧美大片在线观看| 欧美成人国产va精品日本一级| 亚洲国产精品一区二区www在线| 欧美不卡在线| 欧美国产日本韩| 亚洲视频在线观看| 亚洲一区不卡| 国产网站欧美日韩免费精品在线观看| 久久国产福利国产秒拍| 久久久久99| 91久久久在线| 日韩一级成人av| 国产欧美一区二区白浆黑人| 久久精品视频99| 美女国产精品| 一区二区冒白浆视频| 亚洲午夜未删减在线观看| 国产精品一区二区久久久久| 久久久久久久久岛国免费| 麻豆国产va免费精品高清在线| 日韩亚洲欧美一区二区三区| 亚洲精品视频免费| 国产目拍亚洲精品99久久精品| 久久看片网站| 欧美精品日韩综合在线| 性色av一区二区三区在线观看| 欧美在线影院| 日韩视频专区| 亚洲欧美视频一区| 亚洲精品久久久久久久久久久久 | 亚洲欧洲综合另类| 亚洲午夜精品国产| 影音先锋日韩有码| 在线视频中文亚洲|