C 呼叫外部exe程式,並隱藏窗體

2021-10-06 18:35:15 字數 714 閱讀 2497

使用process類,c#可以很方便地呼叫第三方exe,並可以自由地控制是否顯示窗體、如何顯示窗體、實現輸入輸出重定向。

在使用之前,須先包含乙個命名空間:

using system.diagnostics;

process mypro = new process();

mypro.startinfo.filename = "cmd.exe";

mypro.startinfo.useshellexecute = false;

mypro.startinfo.redirectstandardinput = true;

mypro.startinfo.redirectstandardoutput = true;

mypro.startinfo.redirectstandarderror = true;

mypro.startinfo.createnowindow = true;

mypro.start();

string str = string.format(@"installutil.exe windowsservice1.exe &exit");

mypro.standardinput.writeline(str);

mypro.standardinput.autoflush = true;

mypro.waitforexit();

c 呼叫外部exe程式

c 呼叫外部exe程式,首先要 using system.diagnostics 然後開啟乙個新process system.diagnostics.processstartinfo p null system.diagnostics.process proc p new processstarti...

C 程式呼叫外部exe程式

在編寫程式時經常會使用到呼叫可執行程式的情況,本文將簡單介紹c 呼叫exe的方法。在c 中,通過process類來進行程序操作。process類在system.diagnostics包中。using system.diagnostics process p process.start notepad...

C 呼叫外部exe, 並傳參獲取返回值

c 呼叫使用createprocess函式呼叫外部exe傳參並獲取其執行結果。msdn官方位址介紹 bool createprocess lpcwstr pszimagename,an exe file.lpcwstr pszcmdline,parameter for your exe file.l...