Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving file information for the VFP executable running
Shortcut Menu Class
Attaching menu to a top-level form
How to extract frames from AVI files
How to retrieve network parameters for the local computer (including Host name, Domain name, and DNS Server)
Reading header information from AVI file
Storing registration key in the resources of an executable file
Writing to INI file
Retrieving current settings for an ODBC connection
Retrieving Printer Device Context using PrintDlg function
Another way to go online (it is not about choosing an ISP)
Disabling drawing in the VFP form
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Reading VFP settings from the Windows Registry
Retrieving configuration information for the specified workstation (Win2000/XP)
Starting external program from VFP and waiting for its termination
Uploading file to the FTP server using InternetWriteFile
Enumerating connections made to a shared resource for the local computer (WinNT only)
GDI+: Drawing a Pie Chart
Retrieving information about all users currently logged on to the workstation (WinNT only)
Storing the environment strings in cursor
System Image List Viewer
Winsock: resolving an address to a host name
Listing child windows for the Windows desktop
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 (50.19.155.235)
41.95 min.Function: 'SetMapMode'
Function group: 'Coordinate Space and Transformation'
42 min.Example: 'Using the CopyFile'
42.05 min.Function: 'SwitchDesktop'
Function group: 'Window Station and Desktop'
1.86 hrs.
Function group: 'Window Station and Desktop'
4.42 hrs.Example: 'Deleting files into the Recycle Bin'
 Example: 'Deleting a file stored on the FTP server'
7.96 hrs.Function: 'ExitProcess'
7.97 hrs.Example: 'Obtaining names of local and global groups for current user (WinNT/XP/2K)'
17.83 hrs.Example: 'Using the Semaphore object'
 Function: 'SetFilePointerEx'
Function group: 'File Management'
Google
Advertise here!