T
Thomas Mobley
I'm having a problem getting the name of my card readers using
winscard. The same function works in vb6, but I think I must be
missing something here. Anybody see what I'm doing wrong?
Following are my calls to the imports and my values (only the relevent
stuff)
SCardEstablishContext works properly and returns the proper handle
(checks in my vb app)
SCardListReadersW returns success in result, and pReaders get the
correct length (verifies in vb app), but Readers is emptied (even the
null is gone)
++
StringBuilder Readers = new StringBuilder(2048);
Readers.Append("\0");
UInt32 pReaders = 0;
IntPtr pContext = IntPtr.Zero;
int SCardContext = 0;
SCARD_READERSTATEA ReaderState = new SCARD_READERSTATEA(0);
Result = SCardEstablishContext(SCARD_SCOPE_SYSTEM, 0, 0, ref
pContext);
if (Result != 0)
MessageBox.Show(GetErrorMessage(Result));
Result = SCardListReadersW(pContext, null, Readers, ref pReaders);
[DllImport("winscard.dll",
CharSet=System.Runtime.InteropServices.CharSet.Auto)]
public static extern int SCardEstablishContext(int dwScope, int
pvReserved1, int pvReserved2, ref IntPtr phContext);
[DllImport("winscard.dll",
CharSet=System.Runtime.InteropServices.CharSet.Auto)]
public static extern int SCardListReadersW(IntPtr hContext, String
mszGroups, StringBuilder mszReaders, ref UInt32 pcchReaders);
The calls in the winscard lib file are as follows:
Extern WINSCARDAPI LONG WINAPI
SCardListReadersW(
IN SCARDCONTEXT hContext,
IN LPCWSTR mszGroups,
OUT LPWSTR mszReaders,
IN OUT LPDWORD pcchReaders);
extern WINSCARDAPI LONG WINAPI
SCardEstablishContext(
IN DWORD dwScope,
IN LPCVOID pvReserved1,
IN LPCVOID pvReserved2,
OUT LPSCARDCONTEXT phContext);
winscard. The same function works in vb6, but I think I must be
missing something here. Anybody see what I'm doing wrong?
Following are my calls to the imports and my values (only the relevent
stuff)
SCardEstablishContext works properly and returns the proper handle
(checks in my vb app)
SCardListReadersW returns success in result, and pReaders get the
correct length (verifies in vb app), but Readers is emptied (even the
null is gone)
++
StringBuilder Readers = new StringBuilder(2048);
Readers.Append("\0");
UInt32 pReaders = 0;
IntPtr pContext = IntPtr.Zero;
int SCardContext = 0;
SCARD_READERSTATEA ReaderState = new SCARD_READERSTATEA(0);
Result = SCardEstablishContext(SCARD_SCOPE_SYSTEM, 0, 0, ref
pContext);
if (Result != 0)
MessageBox.Show(GetErrorMessage(Result));
Result = SCardListReadersW(pContext, null, Readers, ref pReaders);
[DllImport("winscard.dll",
CharSet=System.Runtime.InteropServices.CharSet.Auto)]
public static extern int SCardEstablishContext(int dwScope, int
pvReserved1, int pvReserved2, ref IntPtr phContext);
[DllImport("winscard.dll",
CharSet=System.Runtime.InteropServices.CharSet.Auto)]
public static extern int SCardListReadersW(IntPtr hContext, String
mszGroups, StringBuilder mszReaders, ref UInt32 pcchReaders);
The calls in the winscard lib file are as follows:
Extern WINSCARDAPI LONG WINAPI
SCardListReadersW(
IN SCARDCONTEXT hContext,
IN LPCWSTR mszGroups,
OUT LPWSTR mszReaders,
IN OUT LPDWORD pcchReaders);
extern WINSCARDAPI LONG WINAPI
SCardEstablishContext(
IN DWORD dwScope,
IN LPCVOID pvReserved1,
IN LPCVOID pvReserved2,
OUT LPSCARDCONTEXT phContext);