Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Listing device drivers in the system: load addresses, names
Obtaining provider name for a specific type of network
Retrieving various system metrics
Using GetSysColor
Pocket PC: enumerating mounted database volumes and databases in the Object Store
Validating URLs using moniker functions
Reading current hardware profile
Accessing the list of Windows Recent Documents
GDI+: converting text strings to images and saving in a graphics file
Retrieving current settings for an ODBC connection
Setting and retrieving the double-click time for the mouse
Retrieving the names of all sections in an initialization file
Opening the Page Setup dialog box to specify the attributes of a printed page
Using custom Simple MapiSendMail class
Pocket PC: retrieving data from the Contacts Database
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Using the SetErrorMode for determining if a floppy drive is ready
Finding the path to the VFP executable running
Retrieving the name and type of all available RAS-capable devices
Using the CopyFile
Who is the first in viewing the Clipboard
Retrieving list of supported paper names (for example, Letter or Legal) for a given printer
Closing Windows
Pocket PC: modifying keys in the System Registry
Listing device drivers in the system: load addresses, names

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
DO declare

LOCAL lcBuffer, lnAllocated, lnBytesNeeded, ii,;
    lnLoadAddr, lcBaseName, lcFullName

lnBytesNeeded = 0

* MSDN: 
* It is a good idea to give EnumDeviceDrivers a large array 
* of LPVOID values, because it is hard to predict 
* how many device drivers there will be at the time 
* you call EnumDeviceDrivers. 

lnAllocated = 16384
lcBuffer = Repli(Chr(0), lnAllocated)

IF EnumDeviceDrivers(@lcBuffer, lnAllocated, @lnBytesNeeded) <> 0
    lcBuffer = Left(lcBuffer, lnBytesNeeded)

    * resulting cursor
    CREATE CURSOR csResult (drivername C(30),;
        loadaddr N(12), fullname C(250))

    FOR ii=1 TO lnBytesNeeded/4
        lnLoadAddr = buf2dword(SUBSTR(lcBuffer, (ii-1)*4+1, 4))

        * retrieving the base name
        lcBaseName = SPACE(50)
        = GetDeviceDriverBaseName(lnLoadAddr,;
            @lcBaseName, Len(lcBaseName))
        lcBaseName = Left(lcBaseName, AT(Chr(0),lcBaseName)-1)

        * retrieving the fully qualified path for the driver
        lcFullName = SPACE(250)
        = GetDeviceDriverFileName(lnLoadAddr,;
            @lcFullName, Len(lcFullName))
        lcFullName = Left(lcFullName, AT(Chr(0),lcFullName)-1)

        INSERT INTO csResult VALUES (;
            lcBaseName, lnLoadAddr, lcFullName)

    GO TOP

FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
    Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
    Asc(SUBSTR(lcBuffer, 4,1)) * 16777216

    DECLARE INTEGER EnumDeviceDrivers IN psapi;
        STRING @lpImageBase, INTEGER cb, INTEGER @lpcbNeeded

    DECLARE INTEGER GetDeviceDriverBaseName IN psapi;
        INTEGER ImageBase, STRING @lpBaseName, INTEGER nSize

    DECLARE INTEGER GetDeviceDriverFileName IN psapi;
        INTEGER ImageBase, STRING @lpFilename, INTEGER nSize

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1771 bytes  
Created: 2001-10-25 21:11:38  
Modified: 2010-08-13 20:16:46  
Visits in 7 days: 74  
Listed functions:
Printer friendly API declarations
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.

Copyright 2001-2017 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.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (
22 sec.
Function group: 'GDI+ Pen'
41 sec.Function: 'CeOidGetInfoEx'
Function group: 'Remote Application Programming (RAPI)'
58 sec.Example: 'How to print FoxPro form'
1.37 min.Function: 'waveOutWrite'
Function group: 'Windows Multimedia'
1.7 min.Function: 'waveInGetDevCaps'
Function group: 'Windows Multimedia'
2.07 min.Function: 'mmioWrite'
Function group: 'Windows Multimedia'
2.37 min.
3.03 min.Example: 'Creating irregularly shaped FoxPro form using transparency color key'
3.42 min.Example: 'Using Month Calendar Control (VFP9, Comctl32.dll)'
3.77 min.Function: 'CeFindNextDatabaseEx'
Function group: 'Remote Application Programming (RAPI)'
Advertise here!