How to use SmartCard library (SCardConnect, SCardEstablishContext, etc.) in Win64? They work perfectly well in Win32.
How to use SmartCard library (SCardConnect, SCardEstablishContext, etc.) in Win64? They work perfectly well in Win32.
I have tested the function in 64-bit and found no problem. The program called C:\Windows\System32\WinSCard. DLL, so It can be used in win64. what problems you have in the process of using?
When I compile my code to 64 bit SCardConnectW returns code 6.
When I compile the same code to 32 bit the return code is 0 and of course everything is working perfectly well.
I have no problem compiling in 64 bits, can you provide a minimal code sample without any privacy.
Connecting to SC
var
FReturnCode : Int64;
FContext: LongInt;
FCard: LongInt;
FATR.Protocol: DWORD;
procedure TNFCWin.Connect(const AReader: string);
begin {Connect}
//Connect to reader using a shared connection
FReturnCode := 0;
FReturnCode := SCardConnectW(FContext,
PWideChar(AReader),
SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0 or SCARD_PROTOCOL_T1,
FCard,
@FATR.Protocol);
if Success
then begin
GetATR(AReader);
FATR.CheckSCType;
CheckBlankCard;
CheckSCTypeFamily;
GetUID;
end;
end; {Connect}
Calling SCardConnectW on Win32 returns 0 but on Win64 returns 6.
An invalid handle was passed to the function, according to error code 6 returned. You can debug it to see if the handle is empty.
May I ask what language your code is using? I suggest you use C++ for testing. This is a sample.
I'm using Embarcadero RAD Studio (Delphi).
Have you tried the C++ example and checked to see if there are invalid handles?
Currently I don't have C++ compiler so I cannot test it.
I found that in fact the problem is in SCardEstablishContext.
FReturnCode := SCardEstablishContext(SCARD_SCOPE_USER,
nil,
nil,
@FContext);
In Win32 FReturnCode is 0 and the handle (FContext) is valid, i.e. SCardIsValidContext(FContext) returns 0.
In Win64 FReturnCode is still 0 but the handle is also 0, thus invalid.
2 people are following this question.