Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving System Error message strings
StrDup returns a pointer to the duplicate of a source VFP string
String representation for disk or memory capacity
Using the Semaphore object to allow only one instance of VFP application running
Retrieving configuration information for the specified server (Win2000/XP)
Retrieving graphic capabilities of default printer
Retrieving the state of your Internet connection
The SQLGetProp() creates a bridge between Visual FoxPro and the ODBC API
Time in milliseconds represented as string (e.g. 1 hour 24 min 36 sec)
Listing INF files in a specified directory
One more way to retrieve environment strings
Retrieving the command line for the VFP session
WAV file recorder
Changing pitch and speed of a wave file
Clipping mouse cursor area
Creating hash values for the list of names
Pocket PC: enumerating mounted database volumes and databases in the Object Store
Retrieving the priority class for the current process
Using the Semaphore object
Current System information
Enhanced GetFont dialog
Enumerating the subkeys of a user-specific key
Finding parameters for the region specified
Opening access to the Microsoft Internet functions for the application
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: 57  
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-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 (107.20.7.65)
25.57 min.Function: 'RegCloseKey'
25.62 min.Example: 'Wininet last error description'
25.68 min.Example: 'Using the CreateFile'
Google
Advertise here!