I have to make use of the WinScard.dll library to access the smart card . I have a Java application that loads and makes use of this library to access the smart card .
32 Bit systems : Initially our application was written for a 32 bit Windows . Hence the following interface to the library worked well .
SCard INSTANCE = (SCard)Native.loadLibrary("C:\\Windows\\SysWOW64\\WinSCard.dll", SCard.class);
public int SCardEstablishContext(int iScope, Pointer pvReserved1, Pointer pvReserved2, /*OUT &long*/LongByReference rRdrlHandle);
public int SCardGetStatusChangeA(int iHandle, int dwTimeout, /*IN/OUT*/SCardReaderState.ByReference rgReaderStates, int cReaders);
64 bit systems : Now while we were migrating our application for a 64 bit windows we realised that to make it work we needed to make all the iHandle long intead of int . Thus the following works
SCard INSTANCE = (SCard)Native.loadLibrary("C:\\Windows\\System32\\winscard", SCard.class);
public int SCardEstablishContext(int iScope, Pointer pvReserved1, Pointer pvReserved2, /*OUT &long*/LongByReference rRdrlHandle);
public int SCardGetStatusChangeA(long iHandle, int dwTimeout, /*IN/OUT*/SCardReaderState.ByReference rgReaderStates, int cReaders);
Note: Point of interest is the first param to the SCardGetStatusChangeA api exposed by the library .
So now my question is this :
Scenario 1 :
Handler obtained : Correct
Scenario 2
( running on a 64 bit system but using 32 bit artifacts ) :
32 bit Java VM
32 bit dll
Keep Long
Handler obtained : Incorrect
Shouldn't the scenario 2 be taken care automatically by the WOW64 subsystem . I read that WOW64 automatically converts the data structures so that a 32 bit application can run on a 64 bit system .
Can someone advice me on how to get my application running on both 32 & 64 bit systems without having the need to change the interface of the iHandle every time ?