Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Enumerating data formats currently available on the clipboard
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Mapping and disconnecting network drives
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: sending email messages (SMTP, port 25)
How to display the Properties dialog box for a file (ShellExecuteEx)
Disk in drive A:
Detecting changes in connections to removable drives (VFP9)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to download a file from the FTP server using FtpGetFile
Using Font and Text functions
How to play AVI file on the _screen
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Using EnumPrinters function to enumerate locally installed printers
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Creating irregularly shaped FoxPro form using transparency color key
Splash Screen for the VFP application
Subclassing CommandButton control to create BackColor property
Vertical Label control
Converting Unicode data from the Clipboard to a character string using a given code page
Enumerating network resources
Creating a console window for Visual FoxPro application
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: 121  
    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.252.150)
    2.73 hrs.Function: 'NetGroupEnum'
    Function group: 'Network Management'
     Example: 'Displaying dimmed window behind VFP top-level form'
    7.72 hrs.Function: 'CeRapiInit'
     Example: 'Terminating all running applications from a VFP program'
     Function: 'RegEnumValue'
    10.34 hrs.Example: 'Pocket PC: custom RAPI class for operating with files and folders on mobile device'
    10.35 hrs.Example: 'Using Beep and Sleep functions to make the old tin buzz sing (WinNT only?)'
     Function: 'ChangeClipboardChain'
    10.46 hrs.Example: 'Copying files as a transacted operation (Vista)'
     Function: 'GetLengthSid'
    Function group: 'Security'
    Google
    Advertise here!