執行外部執行檔 (C#)

出自ProgWiki

跳轉到: 導航, 搜尋

目錄

使用Win32 API

WinExec

//定義
[DllImport("kernel32.dll")]
static extern uint WinExec(string lpCmdLine, uint uCmdShow);
 
//使用
uint SW_HIDE = 0;
uint SW_SHOW = 5;
string strFilename ="notepad.exe";
WinExec(strFilename, SW_SHOW);

CreateProcess

ShellExecute

ShellExecuteEx

使用ActiveX

Shell.Application

<script language="JScript">
    function fnShellExecuteJ()
    {
        var objShell = new ActiveXObject("Shell.Application");
 
        objShell.ShellExecute("notepad.exe", "", "", "open", 1);
    }
</script>

使用.NetFramework

System.Diagnostics.Process.Start

範例:
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); 
psi.FileName = "notepad.exe"; 
psi.Arguments = "c:\\1.txt"; 
System.Diagnostics.Process.Start(psi);
個人工具
名字空間
變換
動作
導航
分類
其他
技術類News或部落格
工具箱