How do I talk to an LPT-port?

Hello!

Using this tutorial (A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums) I bound a dll to my game which should allow me to write to an LPT-port (http://www.highrez.co.uk/Downloads/InpOut32/). The dll has several functions including “IsInpOutDriverOpen()” asking if the LPT driver is open. Calling this function from Unreal4 works perfectly fine. However, calling “Out32()” which is supposed to write to the LPT-port causes my game to crash. This is the error message:

MachineId:18CCDCE3472E427052983BBC3ED39A75 EpicAccountId:

Access violation - code c0000005 (first/second chance not available)

ArenaGame11!FMallocBinned2::Free() ArenaGame11!FMallocThreadSafeProxy::Free() ArenaGame11!FMemory::Free() ArenaGame11!ALibraries::Out32DLL() [c:\users\bierbraua\documents\unreal projects\arenagame11\source\arenagame11\libraries.cpp:61] ArenaGame11!AArenaGame11GameMode::exCountdown() [c:\users\bierbraua\documents\unreal projects\arenagame11\source\arenagame11\arenagame11gamemode.cpp:323] ArenaGame11!FTimerUnifiedDelegate::Execute() ArenaGame11!FTimerManager::Tick() ArenaGame11!UWorld::Tick() ArenaGame11!UGameEngine::Tick() ArenaGame11!FEngineLoop::Tick() ArenaGame11!GuardedMain() ArenaGame11!GuardedMainWrapper() ArenaGame11!WinMain() ArenaGame11!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:255] kernel32 ntdll ntdll ------------------------------------------------------------------------------------------------------------------------------------------------------- And this is what it says in my log thus allowing me to conclude that it finds the function handle but it cannot use the function for whatever reason…: ------------------------------------------------------------------------------------------------------------------------------------------------------- [2016.05.13-08.53.14:117][193]LogClass: DLL Handle not NULL. [2016.05.13-08.53.14:117][193]LogClass: Function Handle not NULL. [2016.05.13-08.53.15:444][193]LogWindows:Error: === Critical error: === Fatal error! ------------------------------------------------------------------------------------------------------------------------------------------------------- I already used this function (Out32()) in some visual-studio-based c+±code (without Unreal4) without any problems.
My code:

Header:

void Out32DLL(short PortAddress, short data);

CPP:

void ALibraries::Out32DLL(short PortAddress, short data) { UE_LOG(LogClass, Log, TEXT(“In Out32.”)) FString filePath = FPaths::Combine(*FPaths::GamePluginsDir(), TEXT(“InpOutBinaries_1501/Win32/”), TEXT(“inpout32.dll”)); // Concatenate the plugins folder and the DLL file.

 UE_LOG(LogClass, Log, TEXT("File path: %s"), (*filePath))
 if (FPaths::FileExists(filePath))
 {
     UE_LOG(LogClass, Log, TEXT("File exists. Path: %s"), (*filePath))
     void *DLLHandle;
     DLLHandle = FPlatformProcess::GetDllHandle(*filePath); // Retrieve the DLL.
     if (DLLHandle != NULL)
     {
         UE_LOG(LogClass, Log, TEXT("DLL Handle not NULL."))
         _Out32 DLLOut32 = NULL; // Local DLL function pointer.
         FString procName = "Out32"; // The exact name of the DLL function.
         DLLOut32 = (_Out32)FPlatformProcess::GetDllExport(DLLHandle, *procName); // Export the DLL function.
         if (DLLOut32 != NULL)
         {
             UE_LOG(LogClass, Log, TEXT("Function Handle not NULL."))                
             DLLOut32(PortAddress, data); // Call the DLL function, with arguments corresponding to the signature and return type of the function.
             
             return; // return to UE
         }
     }
 }
 return;

}
//I call the function like this: Out32DLL(888, 1)

Any ideas?

Thanks in advance!

Best,