tft每日頭條

 > 生活

 > c程序怎麼執行

c程序怎麼執行

生活 更新时间:2024-09-12 00:14:25

c程序怎麼執行?C#程序在某種情況下需要打開另外一個exe程序,下面介紹2種方式:,我來為大家科普一下關于c程序怎麼執行?以下内容希望對你有幫助!

c程序怎麼執行(C調用exe程序)1

c程序怎麼執行

C#程序在某種情況下需要打開另外一個exe程序,下面介紹2種方式:

方法一

string[] the_args = { "1","2","3","4"}; // 被調exe接受的參數 // 被調exe接受的參數,将參數拼接成字符串 string the_args = ""; foreach (string arg in args) { the_args = the_args arg " "; } the_args = the_args.Trim(); string exe_path = pict1.AccessibleName; // 被調exe的路徑 System.Diagnostics.Process.Start(exe_path, the_args);

方法二

// 調用exe的函數 using System.Diagnostics; public bool StartProcess(string exe_path, params string[] args) { string s = ""; foreach (string arg in args) { s = s arg " "; } s = s.Trim(); Process process = new Process();//創建進程對象 ProcessStartInfo startInfo = new ProcessStartInfo(runFilePath, s); // 括号裡是(程序名,參數) process.StartInfo = startInfo; process.Start(); return true; } string exe_path = "E:/CIS.exe"; // 被調exe string[] the_args = { "1","2","3","4"}; // 被調exe接受的參數 StartProcess(exe_path, the_args);

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved