public:
UFUNCTION(BlueprintCallable, Category = "Utilities")
static bool OpenExe(FString ExeURL);
UFUNCTION(BlueprintCallable, Category = "Utilities")
static bool IsExeRunning();
UFUNCTION(BlueprintCallable, Category = "Utilities")
static void CloseExe();
FProcHandle ExeHandle;
bool UTestFunctionLibrary::OpenExe(FString ExeURL)
{
if (FPlatformProcess::CanLaunchURL(*ExeURL))
{
UE_LOG(LogBlueprintFunc, Warning, TEXT("OpenExe CanLaunchURL false"));
return false;
}
ExeHandle = FPlatformProcess::CreateProc(*ExeURL, nullptr, true, false, false, nullptr, 0, nullptr, nullptr);
UE_LOG(LogBlueprintFunc, Warning, TEXT("OpenExe URL:::%s"), *ExeURL);
//FPlatformProcess::CloseProc(currHandle);
bool ret = FPlatformProcess::IsProcRunning(ExeHandle);
return ret;
}
bool UTestFunctionLibrary::IsExeRunning()
{
bool ret = FPlatformProcess::IsProcRunning(ExeHandle);
return ret;
}
void UTestFunctionLibrary::CloseExe()
{
FPlatformProcess::CloseProc(ExeHandle);
}
|