Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Custom FTP Class for Visual FoxPro application
Custom HttpRequest class (WinINet)
Splash Screen for the VFP application
Displaying bitmap using the AlphaBlend function
Establishing connection using the SQLDriverConnect
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
How to put a vertical text scrolling on the form (a movie cast)
How to make a VFP form fading out when released (GDI+ version)
How to make a VFP form fading out when released (GDI version)
Using FlashWindowEx to flash the taskbar button of the VFP application
How to create non-blocking Winsock server
Using WM_COPYDATA for interprocess communication (VFP9)
Winsock: sending email messages (SMTP, port 25)
Creating a mailslot
Detecting changes in connections to removable drives (VFP9)
Peer-to-peer LAN messenger built with Mailslot API functions
Sending a standard message with one or more attached files using default email client
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
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: 103  
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 (184.73.74.47)
4 sec.Example: 'Writing entries to custom Event Log'
3.55 hrs.Example: 'Quering waveform-audio output devices'
3.56 hrs.Example: 'How to print a bitmap file'
4.11 hrs.Example: 'Open and close a Simple MAPI Session'
9.98 hrs.Example: 'Printing Image File, programmatically set print page orientation to landscape'
16.51 hrs.Function: 'WSARecv'
Function group: 'Windows Sockets 2 (Winsock)'
 Function: 'listen'
Google
Advertise here!