C 呼叫外部應用程式

2021-07-30 16:23:41 字數 1371 閱讀 7170

演示說明

此示例演示如何用c#**呼叫記事本程式(notepad.exe)。主程式等待7秒鐘,如果使用者沒有關閉記事本程式,則主程式強制關閉。

示例**

using

system;  

using

system.collections.generic;  

using

system.text;  

// 需要引用的命名空間。

using

system.diagnostics;  

namespace

invokeprogram  

catch

(system.componentmodel.win32exception e)  

"

, e);  

return

;}

// 列印出外部程式的開始執行時間。

, proc.starttime);  

// 等待7秒鐘。

proc.waitforexit(7000);

// 如果這個外部程式沒有結束執行則對其強行終止。

if

(proc.ha***ited == 

false

)

else

, proc.exittime);  

console.writeline("外部程式在結束執行時的返回值:"

, proc.exitcode);  

}

}

}

C 呼叫外部應用程式

呼叫外部程式 1先初始化要啟動的程序 processstartinfo 指定啟動程序時使用的一組值。processstartinfo startinfo new processstartinfo hh.exe decompile.2隱藏程序被啟動是的方式 startinfo.windowstyle ...

C 呼叫 exe應用程式

using system.diagnostics 如果是dos process.start cmd.exe 如果是其他檔案 process.start 絕對路徑 檔名.exe 如何在 中呼叫外部 程式?使用process物件 system.diagnostics.process p new syst...

瀏覽器如何呼叫外部應用程式

1 首先需要編寫乙個登錄檔,副檔名.reg windows registry editor version 5.00 hkey classes root rtmp url rtmp protocol handler url protocol hkey classes root rtmp shell ...