public interface WinScard extends StdCallLibrary
{
WinScard INSTANCE = (WinScard) Native.loadLibrary("winscard", WinScard.class, W32APIOptions.UNICODE_OPTIONS);
public int SCardEstablishContext(int dwScope, Integer pvReserved1, Integer pvReserved2, ByReference phContext);
//LONG WINAPI SCardListReaders(
// _In_ SCARDCONTEXT hContext,
// _In_opt_ LPCTSTR mszGroups,
// _Out_ LPTSTR mszReaders,
// _Inout_ LPDWORD pcchReaders
//);
public int SCardListReadersA(Long hContext, String mszGroups, Buffer mszReaders, IntBuffer pcchReaders);
}
public class ReadCard
{
public static void main(String[] args)
{
WinScard win = WinScard.INSTANCE;
LongByReference phContext = new LongByReference();
int result = win.SCardEstablishContext(2, 0, 0, phContext);
if (result == 0)
{
IntBuffer intBuf = IntBuffer.allocate(100);
CharBuffer buf = CharBuffer.allocate(100);
result = win.SCardListReadersA(phContext.getValue(), null, buf, intBuf);
if (result == 0)
{
System.out.println(new String(buf.array())); //This line is printing some special character.
}
}
}
}
I am getting single special character when I print on the console, I have tried char array, byte arrays for mszReaders but all are returning the same output.
I have sample vb code it is getting the correct reader name.
Unable to identify the problem.
Thanks in advance