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

C++ Programmer's Cookbook

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

進(jìn)程 Process的使用

1 Process?
? 簡(jiǎn)單實(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 夢(mèng)在天涯 閱讀(2283) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): C#/.NET

公告

EMail:itech001#126.com

導(dǎo)航

統(tǒng)計(jì)

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

常用鏈接

隨筆分類(lèi)

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1811735
  • 排名 - 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>
              一区二区三区国产在线观看| 亚洲精品久久久久久下一站| 亚洲一区二区精品视频| 欧美日韩国产电影| 在线视频精品一区| 亚洲视频免费观看| 国产视频综合在线| 媚黑女一区二区| 欧美精品久久久久久久久久| 宅男66日本亚洲欧美视频| 一本色道久久综合一区| 国产一区白浆| 亚洲国产高清一区| 国产精品久久久久久久久久三级| 欧美主播一区二区三区美女 久久精品人 | 在线中文字幕一区| 午夜精品久久久久久久白皮肤| 一区二区三区亚洲| 亚洲美女尤物影院| 国模私拍一区二区三区| 亚洲欧洲精品一区二区三区不卡 | 久久亚洲精品一区| 欧美激情无毛| 久久久91精品国产一区二区三区| 久久夜色精品一区| 午夜精品成人在线视频| 久热精品在线| 久久精品综合| 国产精品对白刺激久久久| 久久中文字幕导航| 国产精品午夜春色av| 亚洲电影第1页| 国产一区二区精品久久| 一区二区三区四区五区精品视频| 国内自拍视频一区二区三区 | 欧美freesex8一10精品| 国产精品青草综合久久久久99 | 一区二区三区免费观看| 在线欧美日韩国产| 欧美一区二区三区四区在线观看地址 | 久久婷婷久久一区二区三区| 欧美日韩在线电影| 亚洲国产日本| 在线免费观看日韩欧美| 欧美一级片久久久久久久| 一本一本久久a久久精品牛牛影视| 久久久久久久高潮| 欧美中文字幕视频在线观看| 国产精品jizz在线观看美国| 亚洲国产成人久久综合| 在线成人国产| 久久久久久有精品国产| 久久久久久尹人网香蕉| 国产精品自拍在线| 欧美亚洲三区| 久久九九免费视频| 激情成人在线视频| 欧美在线一二三| 久久全球大尺度高清视频| 国产亚洲欧美色| 久久久99精品免费观看不卡| 久久久精品日韩| 国内精品久久久久影院 日本资源| 亚洲欧美激情四射在线日 | 久久久久久午夜| 看片网站欧美日韩| 在线观看日韩av电影| 久久天天综合| 欧美国产日韩二区| 99国产精品99久久久久久| 欧美精品久久天天躁| 日韩视频在线一区| 亚洲欧美视频一区二区三区| 国产精品亚洲综合| 久久久91精品| 亚洲国产三级| 亚洲午夜激情| 国产欧美一区二区三区视频 | 最新亚洲一区| 亚洲伊人网站| 国产一区二区三区高清 | 亚洲欧美日韩成人| 久久五月激情| 日韩亚洲成人av在线| 国产精品区一区二区三区| 午夜精品福利视频| 欧美激情一区在线观看| 亚洲午夜久久久久久久久电影网| 国产精品久久久久aaaa九色| 久久国产精品久久国产精品| 欧美激情中文不卡| 亚洲欧美综合精品久久成人| 国产专区欧美专区| 欧美日本一道本| 欧美亚洲综合另类| 亚洲国产天堂久久综合| 欧美一区在线直播| 亚洲激情视频网| 国产精品自拍网站| 欧美国产一区二区在线观看 | 欧美大片在线看| 小处雏高清一区二区三区| 在线观看福利一区| 国产精品爽爽爽| 欧美激情1区2区| 久久爱www.| 亚洲午夜在线| 亚洲国产精品一区制服丝袜 | 欧美一区二区三区四区在线观看| 亚洲国产精品视频| 国产欧美二区| 欧美日韩综合久久| 免费在线播放第一区高清av| 亚洲欧美电影在线观看| 亚洲精品一区二区网址| 六月婷婷一区| 久久精品日韩欧美| 亚洲在线成人精品| 亚洲另类自拍| 亚洲国产老妈| 极品日韩av| 国产亚洲精品久久久久久| 欧美性天天影院| 欧美乱妇高清无乱码| 老司机精品视频一区二区三区| 亚洲欧美在线观看| 亚洲一区二区精品| 一区二区精品| 99视频精品在线| 亚洲国产欧美日韩精品| 欧美国产乱视频| 免费日韩av电影| 欧美成人性生活| 欧美国产欧美亚洲国产日韩mv天天看完整| 欧美综合77777色婷婷| 午夜精品久久久99热福利| 亚洲一区视频在线| 亚洲欧美日韩国产一区二区三区 | 亚洲影院一区| 午夜天堂精品久久久久| 亚洲高清在线观看一区| 久久躁狠狠躁夜夜爽| 欧美一区二区精品久久911| 亚洲在线1234| 亚洲欧美国产精品va在线观看| 在线午夜精品| 亚洲一区自拍| 欧美一区二区三区在线视频| 午夜一区二区三视频在线观看 | 国产一区二区三区在线观看免费| 国产精品一区免费观看| 国产一区二区三区在线免费观看| 国产一区二区高清不卡| 激情一区二区三区| 最新国产成人av网站网址麻豆 | 亚洲视频网站在线观看| 亚洲图片你懂的| 欧美制服丝袜第一页| 久久九九热re6这里有精品| 蜜臀av性久久久久蜜臀aⅴ四虎| 免费日韩av片| 亚洲毛片在线观看.| 亚洲色图综合久久| 久久狠狠亚洲综合| 欧美成人国产一区二区| 欧美日韩黄视频| 国产欧美日本一区二区三区| 狠狠色2019综合网| 亚洲乱码精品一二三四区日韩在线| 一本色道久久综合亚洲精品婷婷 | 激情久久五月天| 99re8这里有精品热视频免费| 这里是久久伊人| 久久婷婷丁香| 亚洲每日在线| 欧美资源在线观看| 欧美人与禽猛交乱配视频| 国产精品综合| 日韩午夜剧场| 久久综合久久综合久久综合| 亚洲人成网在线播放| 午夜精品视频在线观看| 欧美精品一级| 一区二区三区在线视频免费观看| 日韩亚洲成人av在线| 久久九九免费视频| 一本色道久久88精品综合| 久久漫画官网| 国产精品影音先锋| 99热在这里有精品免费| 久久在线免费视频| 亚洲免费视频中文字幕| 欧美精品黄色| 亚洲国产日韩欧美综合久久| 久久不见久久见免费视频1| 亚洲欧洲另类| 麻豆国产精品va在线观看不卡| 国产日产欧美a一级在线| 亚洲视频免费在线| 亚洲欧洲综合|