Re: SCardTransmit Fails

From: Pieter Philippaerts (Pieter_at_nospam.mentalis.org)
Date: 03/25/04


Date: Thu, 25 Mar 2004 20:38:30 +0100


"Barry Hostead" <b.hostead@ntlworld.com> wrote in message
> Public Declare Function SCardTransmit Lib "winscard.dll" _
> ( _
> ByVal hCard As Integer, _
> ByVal pioSendRequest As SCARD_IO_REQUEST, _
> ByRef SendBuff As Byte, _
> ByVal SendBuffLen As Integer, _
> ByVal pioRecvRequest As SCARD_IO_REQUEST, _
> ByRef RecvBuff As Byte, _
> ByRef RecvBuffLen As Integer _
> ) As Integer

This declaration is wrong; both pioSendRequest and pioRecvRequest should be
declared as references to SCARD_IO_REQUEST structures and you're passing
them by value.
I also prefer to declare pioRecvRequest as an IntPtr. You usually don't need
it, so I always pass IntPtr.Zero to it. But this is of course not an error
in the declaration.

So

Public Declare Function SCardTransmit Lib "winscard.dll" (ByVal hCard As
Integer, ByRef pioSendRequest As SCARD_IO_REQUEST, ByRef SendBuff As Byte,
ByVal SendBuffLen As Integer, ByRef pioRecvRequest As SCARD_IO_REQUEST,
ByRef RecvBuff As Byte, ByRef RecvBuffLen As Integer) As Integer

and

Public Declare Function SCardTransmit Lib "winscard.dll" (ByVal hCard As
Integer, ByRef pioSendRequest As SCARD_IO_REQUEST, ByRef SendBuff As Byte,
ByVal SendBuffLen As Integer, ByVal pioRecvRequest As IntPtr, ByRef RecvBuff
As Byte, ByRef RecvBuffLen As Integer) As Integer

should both work.

Regards,
Pieter Philippaerts
Managed SSL/TLS: http://mentalis.org/go.php?sl



Relevant Pages

  • Re: Converting VB6 Structures to .NET
    ... This dll was written by a third party ... I will try ByRef. ... I am using a number of "Declare Function" statments to access the functions ... Public Structure zFuheader ...
    (microsoft.public.dotnet.languages.vb)
  • Re: In VB.Net How do you use the "ScrollWindowEx" function?
    ... Declare Function ScrollWindowEx Lib "user32" (ByVal hwnd As Integer, ... dx As Integer, ByVal dy As Integer, ByRef lprcScroll As Rectangle, ByRef ... lprcClip As Rectangle, ByVal hrgnUpdate As Integer, ByRef lprcUpdate As ...
    (microsoft.public.dotnet.languages.vb)
  • Re: API Help please - How do I find the owner of a file or folder using
    ... equals a VBA Long) so you can't just copy and paste existing Declare ... lpFileName As String, ByVal RequestedInformation As Integer, ByVal ... pSecurityDescriptorAs Byte, ByVal nLength As Integer, ByRef ... lpbOwnerDefaulted As Boolean) As Boolean ...
    (microsoft.public.dotnet.framework.interop)
  • Re: RegOpenKeyEx and QueryValueEx to get values from registry
    ... Private Declare Function RegCreateKeyEx Lib "advapi32.dll" _ ... (ByVal hKey As Long, ByVal lpSubKey As String, _ ... ByVal Reserved As Long, ByVal lpClass As String, _ ... ByRef phkResult As Long, ...
    (microsoft.public.vb.general.discussion)