Hello,
I am trying to export a function in my **.dll **file located in myProject/Plugins directory.
My **importDLL **function is returning TRUE indicating it obtained the DLL file.
However, **GetDllExport **highlighted in red below is failing! (IE. returning false)
I followed this tutorial exactly: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums
The function I am calling from my DLL is known as int chamber(int bullet) which returns a number 1.
//blueprint function library.cpp
#include "BP_BlueprintFunctionLibrary.h"
typedef int(*_getchamberInt)(int intStore);
_getchamberInt m_getchamberIntFromDll;
bool UBP_BlueprintFunctionLibrary::importDLL(FString folder, FString name) //imports the DLL file
{
FString filePath = *FPaths::GamePluginsDir() + folder + "/" + name; //optional
v_dllHandle = FPlatformProcess::GetDllHandle(*filePath); // Retrieve the DLL.
if (v_dllHandle != NULL)
{
return true;
}
else
{
v_dllHandle = FPlatformProcess::GetDllHandle(*name);
if (v_dllHandle != NULL) {
return true;
}
else {
return false; // Return an error
}
}
}
bool UBP_BlueprintFunctionLibrary::importMethodchamber() { //imports the method from the DLL
if (v_dllHandle) {
m_getchamberIntFromDll = NULL;
FString procName = "chamber";
m_getchamberIntFromDll = (_getchamberInt)FPlatformProcess::GetDllExport(v_dllHandle, *procName);
if (m_getchamberIntFromDll != NULL) {
return true;
}
}
return false;
}