因项目需要,得在ue4工程里打开另一个工程,参考了网上很多帖子,因为不太会c,抄的c复制粘贴后会报错,研究了一天后,得出可以使用的方法
创建ue4,选择c++模式
首先新建C++类“Blueprintfunctionlibrary”
?点击下一步,输入命名CommonBlueprintFunctionLibrary

?编写代码.cpp,将你的项目名字换上去
// Fill out your copyright notice in the Description page of Project Settings.
#include "CommonBlueprintFunctionLibrary.h"
#include "../Source/你的项目名字/Public/CommonBlueprintFunctionLibrary.h"
#include "../Runtime/Core/Public/GenericPlatform/GenericPlatformProcess.h"
bool UCommonBlueprintFunctionLibrary::OpenExe(FString URL) {
FProcHandle currHandle = FPlatformProcess::CreateProc(*URL, nullptr, true, false, false, nullptr, 0, nullptr, nullptr);
UE_LOG(LogTemp, Warning, TEXT("URL:::%s"), *URL);
return true;
}
编写代码.h,将你的项目名字换上去
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CommonBlueprintFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class 你的项目名字_API UCommonBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = ExcExe)
static bool OpenExe(FString URL);
};
 
?蓝图部分打出open exe,输入项目位置就可以使用了


?
?
?参考【原创】UE4打开外部".exe"程序 - 知乎
?
|