Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Obtaining addresses for the adapters on the local computer (Win XP/2003/Vista)
Printing text with the Escape function
Retrieving list of supported paper names (for example, Letter or Legal) for a given printer
Using SQLBrowseConnect to connect to a data source through a number of iterative calls (SQL Server)
Using the GetLogicalDriveStrings
Winsock: retrieving information from a host database for a given host name
Determining whether or not the system is connected to the Internet
Minimizing all running applications
Retrieving geometrical parameters of the system desktop window
Using Custom FTP class (DEFINE CLASS ftp As Custom)
Creating hash values for the list of names
GDI+: creating scaled copy of image file
How to display picture stored in enhanced-format metafile (*.emf)
How to enumerate sessions and processes on a specified terminal server
Reading and setting system access privileges for the current process
Reading entries from Event logs
Accessing Windows Control Panel from VFP Application
An alternative way of setting Form.Closable to False
GDI+: reading and writing metadata in JPEG and TIFF files
How to drag a Form not using its Titlebar or Caption
Simple MAPI: how to pick an email recipient from Outlook Express address book
Reading data from INI files
Retrieving the rectangle area where the mouse cursor is confined
GDI+: converting text strings to images and saving in a graphics file
How to retrieve list of system DSNs (Data Source Name) with parameters

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
The code shows how to use the SQLGetPrivateProfileString function to retrieve lists of current Data Sources (either System or User DSNs).

See also:
  • Enumerating ODBC Data Sources available on the local computer

  •  
    #DEFINE ODBC_BOTH_DSN   0  && BOTH may not work as expected
    #DEFINE ODBC_USER_DSN   1
    #DEFINE ODBC_SYSTEM_DSN 2
    DO decl
     
    LOCAL nConfigMode, cSources, cSource, cParamNames, cParam, ii, jj
     
    * saving current value for SQLConfigMode
    nConfigMode = GetConfigMode()
    = SQLSetConfigMode(ODBC_SYSTEM_DSN)
     
    cSources = Chr(0) + GetPS("ODBC Data Sources", Null) + Chr(0)
    CREATE CURSOR csResult (odbcsource C(30), prmname C(20), prmvalue C(200))
     
    ii=1
    DO WHILE .T.
        cSource = GetSubstr(cSources, ii, Chr(0))
        IF EMPTY(cSource)
            EXIT
        ENDIF
     
        cParamNames = GetPS(cSource, Null)
        INSERT INTO csResult VALUES (cSource, "All parameters",;
            STRTRAN(cParamNames, Chr(0), " "))
     
        cParamNames = Chr(0) + GetPS(cSource, Null) + Chr(0)
        jj = 1
        DO WHILE .T.
            cParam = GetSubstr(cParamNames, jj, Chr(0))
            IF EMPTY(cParam)
                EXIT
            ENDIF
            = AddParam(cSource, cParam)
            jj = jj + 1
        ENDDO
        ii = ii + 1
    ENDDO
     
    * restoring SQLConfigMode value
    = SQLSetConfigMode(m.nConfigMode)
     
    GO TOP
    BROWSE NORMAL NOWAIT
    * end of main
     
    PROCEDURE AddParam(cKey, pname)
        LOCAL pvalue
        pvalue = GetPS(cKey, m.pname)
        pvalue = STRTRAN(pvalue, Chr(0),"")
        IF Not EMPTY(pvalue)
            INSERT INTO csResult VALUES (m.cKey,;
                m.pname, m.pvalue)
        ENDIF
     
    FUNCTION GetPS(section, entry)
        LOCAL cBuffer, nLen
        cBuffer = Repli(Chr(0), 250)
        nLen = SQLGetPrivateProfileString(section, entry, "",;
            @cBuffer, Len(cBuffer), "ODBC.INI")
    RETURN Iif(nLen=0, "", SUBSTR(cBuffer, 1, nLen))
     
    FUNCTION GetSubstr(cSource, nIndex, cChar)
        LOCAL nPos1, nPos2
        nPos1 = AT(cChar, cSource, nIndex)
        nPos2 = AT(cChar, cSource, nIndex+1)
        IF MIN(nPos1, nPos2) <> 0
            RETURN SUBSTR(cSource, nPos1+1, nPos2-nPos1-1)
        ENDIF
    RETURN ""
     
    FUNCTION GetConfigMode
        LOCAL nMode
        nMode=0
        = SQLGetConfigMode(@nMode)
    RETURN m.nMode
     
    PROCEDURE decl
        DECLARE INTEGER SQLSetConfigMode IN odbccp32 LONG wConfigMode
        DECLARE INTEGER SQLGetConfigMode IN odbccp32 LONG @pwConfigMode
     
        DECLARE INTEGER SQLGetPrivateProfileString IN odbccp32;
            STRING lpszSection, STRING lpszEntry, STRING lpszDefault,;
            STRING @RetBuffer, INTEGER cbRetBuffer, STRING lpszFilename
     
     
     

    User rating: 10/10 (1 votes)
    Rate this code sample:
    • ~
    2164 bytes  
    Created: 2003-01-22 17:21:27  
    Modified: 2008-04-04 07:54:01  
    Visits in 7 days: 137  
    Listed functions:
    SQLGetConfigMode
    SQLGetPrivateProfileString
    SQLSetConfigMode
    Printer friendly API declarations
    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 (23.22.212.158)
    2.42 hrs.Function: 'GetPrivateProfileString'
    Function group: 'Registry'
     Example: 'Placing On-screen Alert on top of all windows'
     Function: 'CreateMailslot'
    3.68 hrs.Example: 'How to delete all print jobs for a printer'
     
    Function group: 'Path'
    4.72 hrs.Function: 'CryptUnprotectData'
    Function group: 'Cryptography Reference'
    7.16 hrs.Example: 'How to generate GUID values'
     Function: 'CryptDeriveKey'
    14.39 hrs.Function: 'EnumPorts'
    18.23 hrs.Example: 'Obtaining the System and Windows folder names'
    Google
    Advertise here!