Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving file information for the VFP executable running
Retrieving graphic capabilities of your display
Using Change Notification Objects to monitor changes to the printer or print server
Adding and deleting User Accounts
Class library providing access to the System Registry
Enhanced GetFont dialog
Enumerating connections made to a shared resource for the local computer (WinNT only)
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
How to enumerate, add and delete shares on the local computer (WinNT/XP)
How to find when the application started
PocketPC: custom RAPI class for executing routines on remote Windows CE device
Reading and setting Environment variables
Retrieving long values associated with the class of the VFP window
Semi-transparent Form
Using an Event Object. Part A: running an application that creates an Event object
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: retrieving information from a host database for a given host name
Writing to INI file
Enumerating Windows Sound Schemes avaialble to the current user
GDI+: printing vertical text on VFP reports via generated images (VFP9)
How to browse and connect to printers on a network (WinNT)
How to make the caption of a VFP application flashing in the Windows task bar
How to retrieve version information for the specified file
Quering Audio Mixer Device
Retrieving file information for the VFP executable running

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:
API calls GetModuleFileName and GetFileInformationByHandle are used to obtain information about the file behind the current process.
The latter returns populated BY_HANDLE_FILE_INFORMATION structure.

See also:
  • How to retrieve version information for the specified file
  • Showing the Properties dialog box for a file (ShellExecuteEx)
  • Basic Volume Information
  • DO decl
    *| typedef struct _BY_HANDLE_FILE_INFORMATION {
    *|   DWORD    dwFileAttributes;       0:4
    *|   FILETIME ftCreationTime;         4:8
    *|   FILETIME ftLastAccessTime;      12:8
    *|   FILETIME ftLastWriteTime;       20:8
    *|   DWORD    dwVolumeSerialNumber;  28:4
    *|   DWORD    nFileSizeHigh;         32:4
    *|   DWORD    nFileSizeLow;          36:4
    *|   DWORD    nNumberOfLinks;        40:4
    *|   DWORD    nFileIndexHigh;        44:4
    *|   DWORD    nFileIndexLow;         48:4 total 52 bytes
    #DEFINE OF_READ              0
    #DEFINE HFILE_ERROR         -1
    * file type constants
    LOCAL lcFilename, lcFileInfo, lcReopenBuf, hFile,;
        lnFiletype, lnResult
    lcReopenBuf = Repli(Chr(0), 250)
    lcFilename = GetModuleName()
    hFile = OpenFile(lcFilename,;
        @lcReopenBuf, OF_READ+OF_SHARE_DENY_NONE)
    IF hFile = HFILE_ERROR
        ? "Error opening file"
    lcFileInfo = Repli(Chr(0), FILEINFO_SIZE)
    lnResult = GetFileInformationByHandle(hFile, @lcFileInfo)
    lnFiletype = GetFileType(hFile)
    = CloseHandle(hFile)
    IF lnResult <> 0
        ? "Target file:", lcFilename
        ? "File type:", lnFiletype
        ? "File attributes: ", buf2dword(SUBSTR(lcFileInfo, 1,4))
        * the serial number of the volume that contains the file
        ? "Volume serial number:", buf2dword(SUBSTR(lcFileInfo, 29,4))
        ? "File size high:", buf2dword(SUBSTR(lcFileInfo, 33,4))
        ? "File size low:", buf2dword(SUBSTR(lcFileInfo, 37,4))
        * the number of links to this file
        * for the FAT file system this member is always 1
        ? "Number of links:", buf2dword(SUBSTR(lcFileInfo, 41,4))
        * FileIndex: this identifier and the volume serial number 
        * uniquely identify a file.
        * An application can use this identifier and the volume 
        * serial number to determine whether two handles refer 
        * to the same file.
        ? "File index high:", buf2dword(SUBSTR(lcFileInfo, 45,4))
        ? "File index low:", buf2dword(SUBSTR(lcFileInfo, 49,4))
    FUNCTION  GetModuleName
    * retrieves the full path and file name 
    * for the VFP executable running
        LOCAL lcBuffer, lnLen
        lcBuffer = SPACE(512)
        lnLen = GetModuleFileName(0, @lcBuffer, Len(lcBuffer))
    RETURN  Left(lcBuffer, lnLen)
    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
    PROCEDURE  decl
        DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
        DECLARE INTEGER GetFileInformationByHandle IN kernel32;
            INTEGER hFile, STRING @lpFileInformation
        DECLARE INTEGER OpenFile IN kernel32;
            STRING lpFileName, STRING @lpReOpenBuff, INTEGER wStyle 
        DECLARE INTEGER GetModuleFileName IN kernel32;
            INTEGER hModule, STRING @lpFilename, INTEGER nSize
        DECLARE INTEGER GetFileType IN kernel32 INTEGER hFile

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    3086 bytes  
    Created: 2002-01-03 19:19:17  
    Modified: 2005-12-27 10:47:47  
    Visits in 7 days: 93  
    Listed functions:
    Printer friendly API declarations
    My comment:
    The Volume Serial Number value obtained through this code is more accurate comparing to this example: Basic Volume Information. Since the result of the latter is often interpreted by the VFP as a signed integer.
    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 (
    20 sec.Function: 'waveOutUnprepareHeader'
    Function group: 'Windows Multimedia'
    38 sec.Function: 'waveOutGetPosition'
    Function group: 'Windows Multimedia'
    59 sec.Function: 'FindClosePrinterChangeNotification'
    Function group: 'Printing and Print Spooler'
    1.3 min.Updates
    1.68 min.
    Function group: 'System Information'
    2.17 min.Function: 'GetNumberOfPhysicalMonitorsFromHMONITOR'
    2.6 min.Example: 'How to make a VFP form fading out when released (GDI+ version)'
    3.05 min.Function: 'mmioDescend'
    Function group: 'Windows Multimedia'
    3.62 min.Function: 'htonl'
    Function group: 'Windows Sockets 2 (Winsock)'
    5.18 min.Function: 'CeRapiInit'
    Function group: 'Remote Application Programming (RAPI)'
    Advertise here!