Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Setting the date and time that a file was created
Storing registration key in the resources of an executable file
Using GetFileSize
Validating the heap of the calling process
How to view icons stored in executable files (Icon Viewer)
Winsock: reading and setting socket options
Adding an ODBC data source with the SQLConfigDataSource; use automatic or interactive mode
Get the power status of your laptop computer
Obtaining some properties for the Windows desktop using the GetWindowPlacement function
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Dial the Net Automatically
Drawing a rectangle using Windows regular edges and borders
How to draw custom Window Caption on FoxPro form
System Image List Viewer
Windows Shell Icons displayed and exported to ICO files (Vista)
Another way to go online (it is not about choosing an ISP)
Enumerating printer drivers installed
How to Start a Process as Another User (NT/XP/2K)
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Reading the state of mouse buttons within DO WHILE loop
Simple Window Viewer
Starting external program from VFP and waiting for its termination
Using GetBinaryType (WinNT only) to determine the type of an executable file
Attaching menu to a top-level form
Using GetFileSize

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
 
PARAMETERS  lcFilename
 
#DEFINE OF_READ                0
#DEFINE OF_SHARE_DENY_NONE    64
#DEFINE HFILE_ERROR           -1
#DEFINE dwordPlus 0xffffffff + 1
 
LOCAL lpReOpenBuff, hFile, lnSizeLo, lnSizeHi
 
lpReOpenBuff = REPLI (Chr(0), 250)
hFile = OpenFile (lcFilename, @lpReOpenBuff, OF_SHARE_DENY_NONE)
 
IF hFile <> HFILE_ERROR
    lnSizeHi = 0
    lnSizeLo = GetFileSize (hFile, @lnSizeHi)
    RETURN lnSizeHi * dwordPlus + lnSizeLo
    = CloseHandle (hFile)
ELSE
    RETURN 0
ENDIF
 
PROCEDURE  decl
    DECLARE INTEGER GetFileSize IN kernel32;
        INTEGER   hFile,;
        INTEGER @ lpFileSizeHigh
 
    DECLARE INTEGER OpenFile IN kernel32;
        STRING   lpFileName,;
        STRING @ lpReOpenBuff,;
        INTEGER  wStyle
 
    DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
776 bytes  
Created: 2001-08-23 12:00:00  
Modified: 2005-12-27 10:31:24  
Visits in 7 days: 97  
Listed functions:
CloseHandle
GetFileSize
OpenFile
Printer friendly API declarations
My comment:
The GetFileSize returns the result stored in two 32-bit unsigned integers. This is quite a size for any file or device.

Had it return only one 32-bit value -- the maximum of 4,294,967,296 Bytes is not a high-end capacity these days.
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:
jeff9000 | 2005-08-07 15:50:58
The line:
 RETURN lnSizeHi * dwordPlus + lnSizeLo
Needs to be:
Return lnSizeHi * DWORDPLUS + VAL(TRANSFORM(lnSizeLo, "@0"))

In order to work with files over 15GB or something like that. See Universal Thread Message ID:  1039133

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 (184.72.184.104)
5 sec.Example: 'Retrieving a handle to DLL and address of an exported function in it'
5.14 hrs.Function: 'PrintDlgEx'
5.15 hrs.Example: 'GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file'
7.59 hrs.Example: 'How to detect if additional monitor is connected and active'
7.82 hrs.Example: 'Enumerating network interfaces on the local computer'
Language: 'C#'
 Function: 'GetDefaultPrinter'
Function group: 'Printing and Print Spooler'
8.86 hrs.Function: 'GetShellWindow'
10.16 hrs.Example: 'Using InternetSetFilePointer when resuming interrupted download from the Internet'
 Example: 'A class that encrypts and decrypts files using Cryptography API Functions'
13.66 hrs.Function: 'CeRegQueryValueEx'
Google
Advertise here!