Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to print a bitmap file
Winsock: sending email messages (SMTP, port 25)
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
System Image List Viewer
How to display Windows On-Screen Keyboard
Printing Image File, programmatically set print page orientation to landscape
Creating the Save dialog box to specify the drive, directory, and name of a file to save
Using EnumPrinters function to enumerate locally installed printers
How to convert a bitmap file to monochrome format (1 bpp)
Custom HttpRequest class (WinHTTP)
The window and its ancestors
How to download a file from the FTP server using FtpGetFile
Drawing Windows predefined bitmaps using the LoadBitmap functions
Custom FTP Class for Visual FoxPro application
Mapping and disconnecting network drives
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Displaying the associated icons and descriptions for files and folders
How to activate Windows Calculator
Sending email messages with Simple MAPI
Displaying icons in the system tray (VFP9)
Using the high-resolution performance counter

User rating: 3/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
Before you begin:
By default the Windows uses a low-resolution counter -- can be accessed through GetTickCount function -- that returns the number of milliseconds since current Windows session was started.

A 32-bit unsigned number storing the counter value overflows in 49.71 days by definition (0xffffffff / (3600 * 1000 * 24)).

An alternative to the low-resolution counter is the Performance Monitor Counter.

 
DO declare
 
LOCAL cBuffer, nFrequency, nCount, nIndex
cBuffer = Repli(Chr(0), 8)
 
IF QueryPerformanceFrequency(@cBuffer) = 0
    ? "High-resolution performance counter " +;
        "not supported on your system"
    RETURN
ENDIF
 
nFrequency = Large2num(cBuffer)
? "High-res. performance counter frequency:",;
    nFrequency, "counts per second"
?
? "The capacity of the counter in days:",;
    TRANSFORM(0xffffffff * 0xffffffff /;
        (nFrequency * (3600 * 24)), "999,999,999.9999")
 
? "The capacity of the counter in years:",;
    TRANSFORM(0xffffffff * 0xffffffff /;
        (nFrequency * (3600 * 24 * 365.25)), "999,999,999.9999")
?
? "Counts to seconds:"
STORE 0 TO lnValue, lnStored
FOR nIndex=1 TO 10
    = QueryPerformanceCounter(@cBuffer)
    nCount = Large2num(cBuffer)
    ? nCount, nCount/nFrequency
ENDFOR
* end of main
 
FUNCTION Large2num(cBuffer As String) As Number
#DEFINE MAX_DWORD 0xffffffff+1
RETURN buf2dword(SUBSTR(cBuffer, 1,4)) +;
    buf2dword(SUBSTR(cBuffer, 5,4)) * MAX_DWORD
 
FUNCTION buf2dword(cBuffer)
RETURN Asc(SUBSTR(cBuffer, 1,1)) + ;
    Asc(SUBSTR(cBuffer, 2,1)) * 256 +;
    Asc(SUBSTR(cBuffer, 3,1)) * 65536 +;
    Asc(SUBSTR(cBuffer, 4,1)) * 16777216
 
PROCEDURE declare
    DECLARE INTEGER QueryPerformanceCounter IN kernel32;
        STRING @lpPerformanceCount
 
    DECLARE INTEGER QueryPerformanceFrequency IN kernel32;
        STRING @lpFrequency
 

User rating: 3/10 (1 votes)
Rate this code sample:
  • ~
1367 bytes  
Created: 2002-01-24 19:50:10  
Modified: 2009-03-18 11:52:55  
Visits in 7 days: 62  
Listed functions:
QueryPerformanceCounter
QueryPerformanceFrequency
Printer friendly API declarations
My comment:
The capacity of high-resolution counter, normally several thousand years, far exceeds the 49 days limitation for the GetTickCount function. The system resets the high-resolution counter when reboots.

Revised: Mar.18, 2009
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.22.8.126)
1.11 hrs.Example: 'How to enumerate cookies and URL History entries in the cache of the local computer'
 Example: 'How to hot-track menu item selection in top-level form (requires VFP9)'
Google
Advertise here!