Re: SCardGetStatusChange in .NET
From: Pieter Philippaerts (Pieter.nospam_at_mentalis.org)
Date: 11/09/04
- Next message: Walter Poupore [MS]: "Re: where hath capicom gone?"
- Previous message: David Cross [MS]: "Re: Adding a subject alternative name to a request..."
- In reply to: David: "SCardGetStatusChange in .NET"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Tue, 9 Nov 2004 16:35:53 +0100
"David" <dflores@rochester.rr.com> wrote
> I am trying to use the Smart Card Win32 API in VB.NET, some of the
> simple functions are easy to declare like SCardEstablishContext and
> SCardListReaders, but I am having trouble declaring SCardGetStatusChange
> function and the structure SCARD_READERSTATE that is passed in. Can anyone
> help with me the correct declaration for both?
Yes, SCardGetStatusChange was the one that gave me the most problems too.
Here's my (working) declaration for it:
[DllImport("winscard.dll", CharSet=CharSet.Auto)]
internal static extern int SCardGetStatusChange(int hContext, int dwTimeout,
[In, Out] SCARD_READERSTATE[] rgReaderStates, int cReaders);
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
internal struct SCARD_READERSTATE {
[MarshalAs(UnmanagedType.LPTStr)]
public string szReader;
public IntPtr pvUserData;
public int dwCurrentState;
public int dwEventState;
public int cbAtr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=36)]
public byte[] rgbAtr;
}
In my case, it was the [In, Out] before the rgReaderStates parameter that
finally solved all my problems.
> p.s. Whatever happened to Win32API.txt? How come it was never updated?
There's a community site at http://www.pinvoke.net/ that's essentially
trying to accomplish the same thing.
Regards,
Pieter Philippaerts
- Next message: Walter Poupore [MS]: "Re: where hath capicom gone?"
- Previous message: David Cross [MS]: "Re: Adding a subject alternative name to a request..."
- In reply to: David: "SCardGetStatusChange in .NET"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|