Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving local computer and user names
Using the MessageBox Win32 function
WAV file recorder
Converting an integer value to a hexadecimal string
Copying strings through the global memory block
Displaying all TCP connections for the local system
How to control Adobe Reader 9.0 (SDI mode) from VFP application
Playing WAV sounds simultaneously
Printing text on the main VFP window
The window and its ancestors
Using FillMemory
Using InternetGoOnline function
An alternative way of setting Form.Closable to False
Converting command-line string to a set of Unicode argument strings (WinNT only)
Displaying the drive type value
Enumerating ODBC drivers available on the local computer
How to initiate System shutdown
Reading Internet Query options
Retrieving the command line for the VFP session
Using Change Notification Objects to monitor changes to the printer or print server
Configuring DEVMODE structure for a printer
Deleting a file stored on the FTP server
How to perform Base64 encoding/decoding using Cryptography API Functions
How to retrieve version information for the specified file
How to display a dialog box with which the user can add a data source (DSN)

User rating: 0/10 (0 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:
This is a dialog allowing you to create a new data source:


And later if you decide to modify existing data sources:

 
DO decl
 
IF Not CreateDSN("NewDSN")
* 16 = cancelled by the user
* 18 = Could not create a DSN in the registry
* ...
    = MessageB(GetErr(), 64, " Creating New Data Source")
ENDIF
 
* if you decide to manage data sources
= SQLManageDataSources(GetActiveWindow())
 
* end of main
 
FUNCTION CreateDSN(cDSN)
RETURN (SQLCreateDataSource(GetActiveWindow(), cDSN) <> 0)
 
FUNCTION GetErr
* returns error info for the ODBC installer functions
#DEFINE SQL_SUCCESS  0
#DEFINE SQL_SUCCESS_WITH_INFO 1
 
    LOCAL nIndex, cMsg, nBufsize, nErrCode,;
        cResult, nResult
 
    cResult = ""
    FOR nIndex = 1 TO 8
        nBufsize = 512
        cMsg = Repli(Chr(0), nBufsize)
        nErrCode = 0
 
        nResult = SQLInstallerError(nIndex, @nErrCode,;
            @cMsg, nBufsize, @nBufsize)
 
        IF INLIST(nResult, SQL_SUCCESS, SQL_SUCCESS_WITH_INFO)
            cMsg = SUBSTR(cMsg, 1, AT(Chr(0), cMsg)-1)
 
            cResult = cResult + Iif(nIndex=1, "", Chr(13)+Chr(13)) +;
                "Error code: " + LTRIM(STR(nErrCode)) + Chr(13) +;
                cMsg + ".     "
        ELSE
            EXIT
        ENDIF
    ENDFOR
RETURN cResult
 
PROCEDURE decl
    DECLARE INTEGER GetActiveWindow IN user32
    DECLARE INTEGER SQLManageDataSources IN odbccp32 INTEGER hwnd
 
    DECLARE INTEGER SQLCreateDataSource IN odbccp32;
        INTEGER hwnd, STRING lpszDS
 
    DECLARE INTEGER SQLInstallerError IN odbccp32;
        INTEGER iError, INTEGER @pfErrorCode, STRING @lpszErrorMsg,;
        INTEGER cbErrorMsgMax, INTEGER @pcbErrorMsg
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1438 bytes  
Created: 2003-01-31 16:25:07  
Modified: 2009-01-03 15:26:33  
Visits in 7 days: 64  
Listed functions:
GetActiveWindow
SQLCreateDataSource
SQLInstallerError
SQLManageDataSources
Printer friendly API declarations
My comment:
ODBC Data Source Administrator
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)
4 sec.Function: 'WNetOpenEnum'
Function group: 'Windows Networking'
7 sec.Function: 'PathRenameExtension'
Function group: 'Shell Lightweight Utility APIs -- Path Functions'
2.67 hrs.Example: 'Compressing and decompressing files with Windows API Runtime Library routines'
5.05 hrs.Example: 'HOWTO: Use the Win32 API to Access File Dates and Times'
 Function: 'SHEnumKeyEx'
 Example: 'List of addresses in the AutoDial mapping database'
11.93 hrs.Function: 'EnumProcessModules'
11.94 hrs.Example: 'Testing if a connection to an Url can be established'
 Example: 'Retrieving long values associated with the class of the VFP window'
13.74 hrs.Example: 'Using Multimedia Command Strings to play MIDI files'
Google
Advertise here!