代码语言:javascript复制
public static Process StartProcess(string fileName,string args)
{
try
{
fileName = """ fileName """;
//args = """ args """;
Process myProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(fileName, args);
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.StartInfo = startInfo;
return myProcess;
}
catch (Exception ex)
{
UnityEngine.Debug.Log("出错原因:" ex.Message);
}
return null;
}
使用示例:
代码语言:javascript复制string param = """ "立羽" """;
Process pro = PublicFunc.StartProcess(Application.streamingAssetsPath "/PngAddText/TextToPng.exe",param);
pro.Start();
string fingerprint = pro.StandardOutput.ReadLine();
UnityEngine.Debug.Log(fingerprint);
pro.WaitForExit();
pro.Close();