Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Printing text on the main VFP window
Using Shell for performing operations on files
Using the MessageBox Win32 function
Displaying Windows shell folders in TreeView control with Visual FoxPro FLL
How to initiate System shutdown
How to test file attributes (key method for FileExists and DirectoryExists routines)
WAV file recorder
Yet another modal dialog: now HTML-based
An alternative way of setting Form.Closable to False
Current directory of the application
Displaying the drive type value
GDI+: Drawing a Pie Chart
How to display a Task Dialog (Vista)
Returning some basic information for the specified INF file
Using the GetTempFileName
Verifying a file using the Authenticode policy provider
Copying strings through the global memory block
Enumerating sessions established on a server
How to get Special Folders paths
How to print picture stored in enhanced-format metafile (*.emf)
Pocket PC: retrieving data from the Contacts Database
Retrieving geometrical parameters of the system desktop window
Retrieving list of supported paper names (for example, Letter or Legal) for a given printer
Enhanced GetFont dialog
Comparing file times

User rating: 10/10 (2 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
 
*| typedef struct _FILETIME { 
*|     DWORD dwLowDateTime; 
*|     DWORD dwHighDateTime; 
*| } FILETIME, *PFILETIME; 
 
    LOCAL lcTime1, lcTime2, lnResult
 
    lcTime1 = GetLastWriteTime ("c:\i386\Comctl32.dl_")
    lcTime2 = GetLastWriteTime ("c:\winnt\system32\Comctl32.dll")
    lnResult = CompareFileTime (lcTime1, lcTime2)
 
    DO CASE
    CASE lnResult = -1
        ? "First file time is less than second file time"
    CASE lnResult = 0
        ? "First file time is equal to second file time"
    CASE lnResult = 1
        ? "First file time is greater than second file time"
    ENDCASE
RETURN
 
FUNCTION  GetLastWriteTime (lcFilename)
#DEFINE OF_READ   0
#DEFINE OF_WRITE  1
    LOCAL hFile, lcBuffer, lcCreationTm, lcLastAccessTm, lcLastWriteTm
 
    * 8 bytes - size of FILETIME structure
       STORE Repli(Chr(0),8) TO lcCreationTm, lcLastAccessTm, lcLastWriteTm
 
    lcBuffer = REPLI (Chr(0), 250)
    hFile = OpenFile (lcFilename, @lcBuffer, OF_READ)
    IF hFile > 0
        = GetFileTime (hFile, @lcCreationTm, @lcLastAccessTm, @lcLastWriteTm)
        = CloseHandle (hFile)
    ELSE
        *  5 = Access is denied
        * 32 = The file is being used by another process
    ENDIF
RETURN lcLastWriteTm
 
PROCEDURE  decl
    DECLARE INTEGER CompareFileTime IN kernel32;
        STRING lpFileTime1, STRING lpFileTime2
 
    DECLARE GetFileTime IN kernel32;
        INTEGER hFile, STRING @lpCreationTime,;
        STRING @lpLastAccessTime, STRING @lpLastWriteTime
 
    DECLARE INTEGER OpenFile IN kernel32;
        STRING lpFileName, STRING @lpReOpenBuff,;
        INTEGER wStyle
 
    DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
 
 

User rating: 10/10 (2 votes)
Rate this code sample:
  • ~
1604 bytes  
Created: 2001-10-25 20:39:34  
Modified: 2001-10-25 20:44:30  
Visits in 7 days: 85  
Listed functions:
CloseHandle
CompareFileTime
GetFileTime
OpenFile
Printer friendly API declarations
My comment:
When using CompareFileTime there is no need to untwist retrieved FILETIME records into year-month-day-etc. values
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.20.196.179)
3 sec.Function: 'GetDC'
Function group: 'Device Context'
6 sec.Example: 'Creating an Open dialog box to specify the drive, directory, and name of a file to open (Shell32 version)'
3.59 hrs.Example: 'Reading metrics for the currently selected font'
 Example: 'Retrieving a universal form for the drive-based path for a network resource'
4.5 hrs.Example: 'Simple MAPI: how to pick an email recipient from Outlook Express address book'
 Example: 'Custom HttpRequest class (WinINet)'
4.51 hrs.Example: 'Displaying system dialog that selects a folder'
8.19 hrs.Example: 'Vertical Label control'
 Function: 'WTSEnumerateSessions'
10.18 hrs.Function: 'LockResource'
Google
Advertise here!