Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Using Month Calendar Control (VFP9, Comctl32.dll)
Wininet last error description
How to enumerate cookies and URL History entries in the cache of the local computer
How to retrieve number of objects in the Recycle Bin
Reading list of folders and files on FTP server
Reading the state of mouse buttons within DO WHILE loop
Using FlashWindowEx to flash the taskbar button of the VFP application
Adding and deleting User Accounts
Placing On-screen Alert on top of all windows
Pocket PC: custom RAPI class for operating with files and folders on mobile device
Converting image file to .ICO file
Disabling mouse and keyboard input for the main VFP window (with the app still running)
How to adjust monitor brightness (Vista, monitor with DDC support)
How to detect if additional monitor is connected and active
Switching between keyboard layouts
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
Retrieving country-specific dialing information from the Windows Telephony list of countries
Winsock: connecting to a news server (NNTP, port 119)
How to print FoxPro form
Locking and unlocking file of a VFP table
Programmatically removing submenus from VFP main menu
Starting a dialog box for connecting to network resources (mapping network drive)
Retrieving the name of the default printer for the current user on the local computer (Win NT/XP)
Smart Card Database Query Functions

User rating: 9.5/10 (2 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:

Smart cards often are used in conjunction with security and personal privacy. Wherever possible, the resource manager uses the security mechanisms that exist within the underlying operating system (OS) when accessing a reader or smart card.

The smart card resource manager manages the access to readers and smart cards. It identifies and tracks resources, allocates readers and resources across multiple applications, and supports transaction primitives for accessing services that are available on a specified smart card.

The Smart Card Database contains a list of known smart cards, the interfaces and primary service provider of each card, and known smart card readers and reader groups.

Purchase complete VFP solution.
Download ACOS3 Class Library
 
DEFINE CLASS SmartCards As Session
#DEFINE SCARD_SCOPE_USER 0
#DEFINE SCARD_SCOPE_SYSTEM 2
#DEFINE SCARD_S_SUCCESS 0
#DEFINE SCARD_E_NO_SERVICE 0x8010001D
 
    hContext=0
    ReaderGroups=NULL
    Readers=NULL
 
PROCEDURE Init
    THIS.declare
    IF NOT THIS.EstablishContext()
        = MESSAGEBOX("SCardEstablishContext " +;
            "call failed.", 48, "Class Initialization Error")
        RETURN .F.
    ENDIF
 
    THIS.ReaderGroups = CREATEOBJECT("Collection")
    THIS.Readers = CREATEOBJECT("Collection")
 
    THIS.GetReaderGroups
    THIS.GetReaders
 
PROCEDURE Destroy
    THIS.ReleaseContext
 
PROTECTED PROCEDURE EstablishContext
    THIS.ReleaseContext
 
    LOCAL nResult, hContext
    STORE 0 TO nResult, hContext
    nResult = SCardEstablishContext(SCARD_SCOPE_USER,;
        0, 0, @hContext)
 
    THIS.hContext = m.hContext
RETURN (nResult=0)
 
PROTECTED PROCEDURE ReleaseContext
    IF THIS.hContext <> 0
        = SCardReleaseContext(THIS.hContext)
        THIS.hContext=0
    ENDIF
 
PROCEDURE GetReaderGroups
    DO WHILE THIS.ReaderGroups.Count > 0
        THIS.ReaderGroups.Remove(1)
    ENDDO
 
    LOCAL cBuffer, nBufsize, nResult
    nBufsize=1024
    cBuffer=REPLICATE(CHR(0), nBufsize)
 
    nResult = SCardListReaderGroups(THIS.hContext,;
        @cBuffer, @nBufsize)
 
    IF nResult <> SCARD_S_SUCCESS
        RETURN .F.
    ENDIF
 
    LOCAL nItemCount, nItemIndex, cItem
    nItemCount = ALINES(arrSCardItems, cBuffer, CHR(0))
 
    FOR nItemIndex=1 TO nItemCount
        cItem = STRTRAN(arrSCardItems[nItemIndex], CHR(0), "")
        IF LEN(m.cItem) > 0
            THIS.ReaderGroups.Add(m.cItem)
        ENDIF
    NEXT
 
PROCEDURE GetReaders()
    DO WHILE THIS.Readers.Count > 0
        THIS.Readers.Remove(1)
    ENDDO
 
    LOCAL cBuffer, nBufsize, nResult
    nBufsize=1024
    cBuffer=REPLICATE(CHR(0), nBufsize)
 
    nResult = SCardListReaders(THIS.hContext,;
        NULL, @cBuffer, @nBufsize)
 
    IF nResult <> SCARD_S_SUCCESS
        RETURN .F.
    ENDIF
 
    LOCAL nItemCount, nItemIndex, cItem
    nItemCount = ALINES(arrSCardItems, cBuffer, CHR(0))
 
    FOR nItemIndex=1 TO nItemCount
        cItem = STRTRAN(arrSCardItems[nItemIndex], CHR(0), "")
        IF LEN(m.cItem) > 0
            THIS.Readers.Add(m.cItem)
        ENDIF
    NEXT
 
PROTECTED PROCEDURE declare
    DECLARE LONG SCardEstablishContext IN Winscard;
        INTEGER dwScope, INTEGER pvReserved1,;
        INTEGER pvReserved2, INTEGER @phContext
 
    DECLARE LONG SCardReleaseContext IN Winscard;
        INTEGER hContext
 
    DECLARE LONG SCardListReaderGroups IN Winscard;
        LONG hContext, STRING @mszGroups,;
        LONG @pcchGroups
 
    DECLARE LONG SCardListReaders IN Winscard;
        INTEGER hContext, STRING mszGroups,;
        STRING @mszReaders, LONG @pcchReaders
 
    DECLARE LONG SCardListCards IN Winscard;
        INTEGER hContext, INTEGER pbAtr,;
        INTEGER rgguidInterfaces, LONG cguidInterfaceCount,;
        STRING @mszCards, LONG @pcchCards
 
    DECLARE LONG SCardListInterfaces IN Winscard;
        INTEGER hContext, STRING szCard,;
        STRING @pguidInterfaces, LONG @pcguidInterfaces
 
    DECLARE LONG SCardGetProviderId IN Winscard;
        INTEGER hContext, STRING szCard,;
        STRING @pguidProviderId
 
    DECLARE INTEGER StringFromGUID2 IN ole32;
        STRING rguid, STRING @lpsz, INTEGER cchMax
 
ENDDEFINE
 

User rating: 9.5/10 (2 votes)
Rate this code sample:
  • ~
3123 bytes  
Created: 2008-10-22 20:30:53  
Modified: 2009-12-15 16:03:29  
Visits in 7 days: 81  
Listed functions:
SCardEstablishContext
SCardGetProviderId
SCardListCards
SCardListInterfaces
SCardListReaderGroups
SCardListReaders
SCardReleaseContext
StringFromGUID2
Printer friendly API declarations
My comment:
Use the following code to test the SmartCard classes:

LOCAL oSmartCards As SmartCards
oSmartCards = CREATEOBJECT("SmartCards")

FOR EACH cReaderGroup IN oSmartCards.ReaderGroups
        ? cReaderGroup
NEXT

FOR EACH cReader IN oSmartCards.Readers
        ? cReader
NEXT
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.235.20.17)
48.6 min.Example: 'Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window'
48.63 min.Example: 'Reading and setting explicit Application User Model ID for the current process (Win7)'
55.38 min.Function: 'StrToInt'
55.47 min.Example: 'Opening the Page Setup dialog box to specify the attributes of a printed page'
1.03 hrs.Example: 'Converting Unicode data from the Clipboard to a character string using a given code page'
 Example: 'Splash Screen for the VFP application'
1.75 hrs.Function: 'DeleteMenu'
Function group: 'Menu'
4.81 hrs.Example: 'How to change display settings: screen resolution, screen refresh rate'
Language: 'C++'
 
Function group: 'GDI+ StringFormat'
 Function: 'AVIStreamGetFrameClose'
Function group: 'Windows Multimedia'
Google
Advertise here!