打开外部 exe程序
FProcHandle FWindowsPlatformProcess::CreateProc(const TCHAR* URL, const TCHAR* Parms, bool bLaunchDetached, bool bLaunchHidden, bool bLaunchReallyHidden, uint32* OutProcessID, int32 PriorityModifier, const TCHAR* OptionalWorkingDirectory, void* PipeWriteChild, void* PipeReadChild)
创建新进程及其主线程。新流程运行
*在调用进程的安全上下文中指定的可执行文件。
*@param URL可执行文件名
*@param Parms命令行参数
*@param bLaunchDetached如果为true,新进程将有自己的窗口
*@param bLaunchHidden如果为true,新进程将在任务栏中最小化
*@param bLaunchReallyHidden如果为true,新进程将没有窗口或不在任务栏中
*@param OutProcessId如果非空,则将用ProcessId填充
*@param优先级修改器-2空闲,-1低,0正常,1高,2高
*@param OptionalWorkingDirectory在运行程序时启动,或NULL使用当前工作目录
*@param PipeWrite可选句柄到管道以重定向输出
*@return用于其他进程函数的进程句柄
FString videoExePath = TEXT("E:/VitsTTS/ttsServer.exe");
FPlatformProcess::CreateProc(*videoExePath, TEXT("AIVoiceGenerate"), true, false, false, nullptr, 0, nullptr, nullptr);
打开外部 控制台exe程序
控制台程序打开 和 普通exe程序打开 最重要的区别设置是 OptionalWorkingDirectory 参数 传入程序所在的文件夹路径 *videoDirPath,要不然程序中的配置文件无法自动读取
FString videoExePath = TEXT("E:/VitsTTS/ttsServer.exe");
FString videoDirPath = TEXT("E:/VitsTTS/");
ttsExeHandle = FPlatformProcess::CreateProc(*videoExePath, TEXT("AIVoiceGenerate"), false, false, true, nullptr, 0, *videoDirPath, nullptr);
FPlatformProcess::CloseProc(ttsExeHandle);
FPlatformProcess::TerminateProc(ttsExeHandle);
打开外部 exe 程序、网页、各种类型文件
bool FWindowsPlatformProcess::LaunchFileInDefaultExternalApplication( const TCHAR* FileName, const TCHAR* Parms , ELaunchVerb::Type Verb , bool bPromptToOpenOnFailure )
适合打开非控制台程序 和 各种外部文件
FString videoExePath= TEXT("E:/VitsTTS/ttsServer.exe");
FPlatformProcess::LaunchFileInDefaultExternalApplication(*videoExePath);
FString videoExePath= TEXT("E:/VitsTTS/qqq.png");
FPlatformProcess::LaunchFileInDefaultExternalApplication(*videoExePath);
FString videoExePath= TEXT("https://yiyan.baidu.com/");
if(FPlatformProcess::CanLaunchURL(*videoExePath))
{
FPlatformProcess::LaunchURL(*videoExePath)
}
其他方法,需要自行测试
FString videoExePath = TEXT("E:/VitsTTS/ttsServer.exe");
FString videoDirPath = TEXT("E:/VitsTTS/");
FPlatformProcess::ExecProcess(*videoExePath)
FPlatformProcess::ExecElevatedProcess(*videoExePath)
FPlatformProcess::ExploreFolder(*videoExePath)