Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Listing INF files in a specified directory
Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)
Reading header information from AVI file
Saying "Hello World!" with VFP and WinAPI
System and Local Time values
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Using Shell for performing operations on files
Using the RestartDialog function -- restarting Windows
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Confining Windows calculator inside the VFP main window
Creating a mailslot
Displaying bitmap using the AlphaBlend function
GetFileOwner - Get the owner of an NTFS file
How to empty the Recycle Bin
How to Start a Process as Another User (NT/XP/2K)
Retrieveing information about the active window (even if it is not owned by the calling process)
Subclassing CommandButton control to create BackColor property
Using the IsWindowEnabled function
Using the Semaphore object to allow only one instance of VFP application running
Clipping mouse cursor area
Comparing file times
Creating a unique filename based on existing filename
Displaying standard progress dialog box when copying files
Enumerating Volumes and Volume Mounting Points (NTFS)
Listing INF files in a specified directory

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 decl
 
#DEFINE INVALID_HANDLE_VALUE -1
 
#DEFINE INF_STYLE_NONE        0
#DEFINE INF_STYLE_OLDNT       1
#DEFINE INF_STYLE_WIN4        2
 
    LOCAL lcPath, lcBuffer, lnRequired, lnResult, lnInfStyle
 
*    lcPath = "c:\windows\system"
*    lcPath = "c:\windows\inf\"
*    lcPath = "c:\winnt\system32"
    lnInfStyle = INF_STYLE_OLDNT
 
    lnRequired = 0
 
    * first call with insufficient buffer 
    * just to define how much space should be allocated
    * Possible error code = 122:
    * The data area passed to a system call is too small
    lcBuffer = ""
 
    lnResult = SetupGetInfFileList (lcPath,;
        lnInfStyle, @lcBuffer, Len(lcBuffer), @lnRequired)
 
    IF lnRequired > 0
        * output buffer resized as required
        lcBuffer = Repli(Chr(0), lnRequired)
 
        * another call
        lnResult = SetupGetInfFileList (lcPath,;
            INF_STYLE_OLDNT, @lcBuffer, lnRequired, @lnRequired)
 
        IF lnResult <> 0
            * resulting cursor
            CREATE CURSOR csResult (infname C(20), infstyle N(2),;
                result L, errline N(6))
 
            LOCAL ii, ch, lcFilename
            lcFilename = ""
 
            * WinMe allocates a huge buffer, but returns
            * only a few file names in it -- only a part of existing
            * INF files
            lcBuffer = Left(lcBuffer, AT(Chr(0)+Chr(0), lcBuffer)+1)
 
            * scan the buffer to retrieve INF file names
            FOR ii=1 TO Len(lcBuffer)
                ch = SUBSTR (lcBuffer, ii,1)
                IF ch = Chr(0)
                    IF Not EMPTY(lcFilename)
                        = testInfFile (lcFilename, lnInfStyle)
                        lcFilename = ""
                    ENDIF
                ELSE
                    lcFilename = lcFilename + ch
                ENDIF
            ENDFOR
        ENDIF
    ENDIF
 
    IF USED ("csResult")
        SELECT csResult
        GO TOP
        BROW NORMAL NOWAIT
    ENDIF
 
PROCEDURE  testInfFile (lcFilename, lnInfStyle)
    LOCAL hFile, lnErrline
    lnErrline = 0
 
    hFile = SetupOpenInfFile (lcFilename, 0,;
        lnInfStyle, @lnErrline)
 
    IF hFile <> INVALID_HANDLE_VALUE
        = SetupCloseInfFile (hFile)
    ENDIF
 
    INSERT INTO csResult VALUES (lcFilename, lnInfStyle,;
        hFile <> INVALID_HANDLE_VALUE, m.lnErrline)
RETURN
 
PROCEDURE  decl
    DECLARE INTEGER SetupOpenInfFile IN setupapi;
        STRING FileName, INTEGER InfClass,;
        INTEGER InfStyle, INTEGER @ ErrorLine
 
    DECLARE INTEGER SetupGetInfFileList IN setupapi;
        STRING DirectoryPath, INTEGER InfStyle,;
        STRING @ ReturnBuffer, INTEGER ReturnBufferSize,;
        INTEGER @ RequiredSize
 
    DECLARE SetupCloseInfFile IN setupapi INTEGER InfHandle
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
2399 bytes  
Created: 2001-10-24 19:52:51  
Modified: 2001-10-24 20:11:18  
Visits in 7 days: 25  
Listed functions:
SetupCloseInfFile
SetupGetInfFileList
SetupOpenInfFile
Printer friendly API declarations
My comment:
WinNT4 lists all INF files in the directory -- Ok; but WinME -- it lists only a few of them, though it allocates a buffer that is large enough to place all existing INF files in the directory.

So far I have no other explanation except a bug in WinMe (4.90.3000) implementation of this function.

Whoever can test this code with more Windows versions, please share the results here.
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-2010 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.0.85), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (38.107.191.106)
5.22 min.Function: 'waveInGetDevCaps'
Function group: 'Windows Multimedia'
9.37 min.Example: 'Obtaining memory performance information for the system'
16.65 min.
Function group: 'File System'
49.12 min.
Function group: 'Error Handling'
53.83 min.Function: 'mixerClose'
Function group: 'Windows Multimedia'
55.8 min.Function: 'waveInGetErrorText'
Function group: 'Windows Multimedia'
1.02 hrs.Function: 'SetHandleInformation'
5 day(s)Solution: 'Extended MessageBox library (assembly) for .NET'
Google
Advertise here!