Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Setting the date and time that a file was created
Simple Window Viewer
Using FillMemory
Winsock: reading email messages (POP3, port 110)
Adding an ODBC data source with the SQLConfigDataSource; use automatic or interactive mode
Browsing Windows Known Folders (Special Folders)
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
Retrieving the names of all sections in an initialization file
Running a regular FoxPro form while main VFP window is minimized
Simple printer queue monitor: deletes, pauses, resumes print jobs for local printer
How to view icons stored in executable files (Icon Viewer)
Obtaining list of tables stored in an ODBC Data Source
Printf-style formatted text output in VFP
Smart Card Database Query Functions
Using NetWkstaTransportEnum to obtain MAC Address of remote server
How to register custom Event Log source
Pocket PC: custom RAPI class for operating with files and folders on mobile device
Retrieving names for the registered clipboard formats
Displaying OS Memory Status
Enumerating network resources
Enumerating print jobs and retrieving information for default printer (JOB_INFO_1 structures)
Extended OS Version info
How to obtain Content-Type value for a file type from the System Registry
DiskFreeSpace class

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
 
dspace = CREATEOBJECT("Tdspace", "c:")
IF dspace.errorcode = 0
    lcMask = "999,999,999,999,999"
 
    ? "Free bytes available to the calling thread:",;
        TRANS(dspace.threadFree, lcMask)
 
    ? "Total free bytes on the disk:",;
        TRANS(dspace.globalFree, lcMask)
 
    ? "Total bytes available to the calling thread:",;
        TRANS(dspace.threadTotal, lcMask)
ELSE
    ? "Error code: ", dspace.errorcode
ENDIF
 
DEFINE CLASS Tdspace As Session
#DEFINE MAX_INTEGER 0x100000000
    threadFree=0
    threadTotal=0
    globalFree=0
    errorcode=0
 
FUNCTION Init(lcPath)
    THIS.declare
    THIS.GetInfo(lcPath)
 
PROCEDURE GetInfo(lcPath)
    IF TYPE("lcPath") <> "C"
        lcPath = ""
    ENDIF
    LOCAL lpFreeBytesAvailable, lpTotalNumberOfBytes,;
        lpTotalNumberOfFreeBytes,;
        threadFreeLo, threadFreeHi, threadTotalLo,;
        threadTotalHi, freeLo, freeHi
 
    STORE Repli(Chr(0), 8) TO lpFreeBytesAvailable,;
        lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes
 
    IF GetDiskFreeSpaceEx(lcPath, @lpFreeBytesAvailable,;
        @lpTotalNumberOfBytes, @lpTotalNumberOfFreeBytes) = 1
 
        threadFreeLo = THIS.buf2dword(SUBSTR(lpFreeBytesAvailable, 1,4))
        threadFreeHi = THIS.buf2dword(SUBSTR(lpFreeBytesAvailable, 5,4))
        threadTotalLo = THIS.buf2dword(SUBSTR(lpTotalNumberOfBytes, 1,4))
        threadTotalHi = THIS.buf2dword(SUBSTR(lpTotalNumberOfBytes, 5,4))
        freeLo = THIS.buf2dword(SUBSTR(lpTotalNumberOfFreeBytes, 1,4))
        freeHi = THIS.buf2dword(SUBSTR(lpTotalNumberOfFreeBytes, 5,4))
 
        THIS.threadFree = THIS.GetLargeInt(threadFreeLo, threadFreeHi)
        THIS.threadTotal = THIS.GetLargeInt(threadTotalLo, threadTotalHi)
        THIS.globalFree = THIS.GetLargeInt(freeLo, freeHi)
        THIS.errorcode = 0
    ELSE
        STORE 0 TO THIS.threadFree, THIS.threadTotal, THIS.globalFree
        THIS.errorcode = GetLastError()
    ENDIF
 
PROTECTED PROCEDURE declare
    DECLARE INTEGER GetLastError IN kernel32
 
    DECLARE SHORT GetDiskFreeSpaceEx IN kernel32;
        STRING lpDirectoryName, STRING @lpFreeBytesAvailable,;
        STRING @lpTotalNumberOfBytes, STRING @lpTotalNumberOfFreeBytes
 
PROTECTED 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
 
PROTECTED FUNCTION GetLargeInt(lo, hi)
RETURN MAX_INTEGER * m.hi + m.lo
 
ENDDEFINE
 
 
 

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
2344 bytes  
Created: 2001-08-13 12:00:00  
Modified: 2006-04-17 14:55:25  
Visits in 7 days: 72  
Listed functions:
GetDiskFreeSpaceEx
GetLastError
Printer friendly API declarations
My comment:
DiskSpace() is not reliable on big disks or NTFS (pre VFP7)
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 (50.16.132.180)
5.48 min.Function: 'GdipGetPageScale'
2.69 hrs.Example: 'Loading a string resource from an executable file'
 Example: 'Retrieving the name of the network resource associated with a local device'
 Function: 'SetBkMode'
3.45 hrs.Example: 'How to display advanced Task Dialog (Vista)'
5.06 hrs.Function: 'AssignProcessToJobObject'
Function group: 'Process and Thread'
6.04 hrs.Example: 'Retrieving local computer and user names'
 Example: 'Sending email messages with Simple MAPI'
 Function: 'CreateWindow'
7.02 hrs.Example: 'Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window'
Google
Advertise here!