+ Reply to Thread
Results 1 to 2 of 2

How can I show the results of the following code?

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    How can I show the results of the following code?

    Hi all,

    I have written the following using winscard.dll in Excel VBA.

    When I compile it I get no errors however I cannot get it to display anything on the form.

    This is all in the userform1.

    -----------------------------------------------------------------------

    Private Const SCARD_SCOPE_USER As Long = &H0
    Private Const SCARD_SCOPE_SYSTEM As Long = &H2
    Private Const SCARD_SHARE_SHARED As Long = &H2
    Private Const SCARD_SHARE_EXCLUSIVE As Long = &H1
    Private Const SCARD_SHARE_DIRECT As Long = &H3
    Private Const SCARD_PROTOCOL_T0 As Long = &H1
    Private Const SCARD_PROTOCOL_T1 As Long = &H2

    Private Const SCARD_DEFAULT_READERS As String = "SCard$DefaultReaders\000"

    Private Declare PtrSafe Function SCardEstablishContext Lib "winscard.dll" (ByVal dwScope As Long, _
    ByVal pvReserved1 As Long, _
    ByVal pvReserved2 As Long, _
    ByRef phContext As SCARDCONTEXT _
    ) As Long

    Private Declare PtrSafe Function SCardReleaseContext Lib "winscard.dll" (ByRef phContext As SCARDCONTEXT) As Long

    Private Declare PtrSafe Function SCardConnect Lib "winscard.dll" (ByRef phContext As SCARDCONTEXT, _
    ByVal dwShareMode As Long, _
    ByVal szReader As String, _
    ByVal dwPreferredProtocols As Long, _
    ByRef phCard As Long, _
    ByRef pdwActiveProtocol As Long _
    ) As Long

    Private Declare PtrSafe Function SCardListReaders Lib "winscard.dll" (ByRef phContext As SCARDCONTEXT, _
    ByVal dwShareMode As Long, _
    ByVal mszGroups As String, _
    ByRef mszReaders As String, _
    ByRef pcchReaders As Long _
    ) As Long

    Private Type SCARDCONTEXT
    CardContext1 As Long
    ReaderName As String
    End Type

    Sub GetContext()

    Dim lReturn As Long
    Dim RSVD1 As Long, RSVD2 As Long
    Dim myContext As SCARDCONTEXT

    lReturn = SCardEstablishContext(SCARD_SCOPE_USER, RSVD1, RSVD2, myContext)

    Debug.Print "SCardEstablishContext: Return =" & lReturn & "" _
    ; " myContext.CardContext1 = " & myContext.CardContext1 & _
    " myContext.ReaderName = " & Chr(34) & myContext.ReaderName & Chr(34)

    Dim ListOfReaders As String, lenListOfReaders As Long

    lReturn = SCardListReaders(myContext, SCARD_SHARE_SHARED, SCARD_DEFAULT_READERS, ListOfReaders, lenListOfReaders)

    Debug.Print "SCardListReaders: Return =" & lReturn & _
    " ListOfReaders = " & Chr(34) & ListOfReaders & Chr(34) & _
    " lenListOfReaders = " & lenListOfReaders

    lReturn = SCardReleaseContext(myContext)
    Debug.Print "SCardReleaseContext: Return =" & lReturn

    End Sub



    Private Sub UserForm_Click()

    End Sub


    ---------------------------------------------

    Some help would be appreciated.

  2. #2
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    25,684

    Re: How can I show the results of the following code?

    Hello and welcome to the forum. Unfortunately your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    In addition when posting code also note our rule about wrapping any code in CODE tags so that it indents correctly.
    Richard Buttrey

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1