none
winscard.dll question RRS feed

  • Question

  • 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
    'http://msdn.microsoft.com/en-us/library/aa379479(VS.85).aspx
    '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,


    • Edited by mikwilmot25 Tuesday, October 1, 2013 11:43 AM
    Monday, September 30, 2013 7:34 PM