Consulting

Results 1 to 3 of 3

Thread: How do use winscard.dll within VBA?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    How do you use winscard.dll within VBA?

    I am using Access 2010 with a SQL Server 2005 backend. I am using VBA to manipulate the code in SQL Server. Last week I was given a requirement to read a CAC( card inserted in an ActivIdentity card reader ), find the user who is logged in and then log into the SQL Server as that user. I am using winscard.dll to connect to the card reader.

    The following is the declaration I am using:
    'SCardEstablishContext
    'LONG STDCALL SCardEstablishContext(DWORD(in), LPCVOID(in), LPCVOID(in),
    ' LPSCARDCONTEXT(out))
    Public Declare Function SCardEstablishContext Lib "winscard.dll" ( _
    ByVal dwScope As Long, _
    ByVal pvReserved1 As Long, _
    ByVal pvReserved2 As Long, _
    ByRef phContext As Long _
    ) As Long
    This is how I am calling the function:
    ...
    Dim lParam1 As Long
    Dim lParam4 As Long
    Dim lReturn As Long

    lParam1 = 1
    lReturn = SCardEstablishContext(lParam1, 0, 1, lParam4)
    ...
    The function does not error out, however, the lReturn is = "-2146435055"

    QUESTIONS:
    How do I set up SCardEstablishContext to run properly?
    How do I set up lParam4 to hold all of the information after SCardEstablishContext runs correctly?
    Thanks in advance,
    Last edited by mikwilmot; 10-01-2013 at 06:52 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •