Hi All, Im after some advice.
Im trying to connect a cardreader to our UE4.27 project, the SDK for the cardreader uses.
winscard.h
When i import it the following compile errors
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winnt.h(584): warning C4005: ‘TEXT’: macro redefinition
C:\Program Files\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\HAL/Platform.h(1085): note: see previous definition of ‘TEXT’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7542): error C4668: ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7548): error C4668: ‘_WIN32_WINNT_WIN10_RS1’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7553): error C4668: ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7557): error C4668: ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7564): error C4668: ‘_WIN32_WINNT_WIN10_RS2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7574): error C4668: ‘_WIN32_WINNT_WIN10_RS2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7578): error C4668: ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7583): error C4668: ‘_WIN32_WINNT_WIN10_RS3’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7777): error C4668: ‘_WIN32_WINNT_WIN10_RS2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12249): error C4668: ‘_WIN32_WINNT_WIN10_RS3’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12266): error C4668: ‘_WIN32_WINNT_WIN10_RS3’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12285): error C4668: ‘_WIN32_WINNT_WIN10_RS2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12404): error C4668: ‘_WIN32_WINNT_WIN10_RS3’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
After some searches have tried
so i have
#ifdef TEXT
#undef TEXT // Delete macro UE4
#endif
include <winscard.h>
#ifdef TEXT
#undef TEXT // Delete macro Win32
#endif
#define TEXT(quote) __ TEXT(quote) // Define macro UE4
and in my build.cs file
new string
{
“_WIN32_WINNT_WIN10_TH2”,“_WIN32_WINNT_WIN10_RS1”,
“_WIN32_WINNT_WIN10_RS2”,
“_WIN32_WINNT_WIN10_RS3”,
“_WIN32_WINNT_WIN10_RS4”,
“_WIN32_WINNT_WIN10_RS5”
}
);
so now it compiles with an empty file but when i do anything like
bool UACSCardReader::EstablishContext()
{
retCode = SCardEstablishContext(SCARD_SCOPE_USER,NULL,NULL, &hContext);
if (retCode != SCARD_S_SUCCESS)
{
return false;
}
else
{
return true;
}
}
it throws this error
ACSCardReader.cpp.obj : error LNK2019: unresolved external symbol SCardEstablishContext referenced in function “public: static bool __cdecl UACSCardReader::EstablishContext(void)” (?EstablishContext@UACSCardReader@@SA_NXZ)
Am i missing something or doing something stupid
The only other option i can think of using WinSCard.dll using FPlatformProcess::GetDllHandle and using FPlatformProcess::GetDllExport to get the methods
I have done this before to connect to other hardware to connect to a plc and usb devices, however in this situation i would prefer to find a solution to use include <winscard.h>
Thanks