High Resolution Timer


Updated February, 2005 for Windows XP

struct res, lowPart as ulong, highPart as long

'see if system has a high frequency counter
calldll #kernel32, "QueryPerformanceFrequency",_
res as struct, result as boolean

if result=0 then
    print "System doesn't support hi-res counter."
    end
else
    freq=largeInt2Dec(res.lowPart.struct, res.highPart.struct)

    calldll #kernel32, "QueryPerformanceCounter",_
        res as struct, result as boolean
    first=largeInt2Dec(res.lowPart.struct, res.highPart.struct)

    calldll #kernel32, "QueryPerformanceCounter",_
        res as struct, result as long
    second=largeInt2Dec(res.lowPart.struct, res.highPart.struct)

    print "Frequency in counts per second: ";freq
    print "First value: ";first
    print "Second value: ";second
    print "Time (ticks) ellapsed: ";second-first
end if
end

'Stefan Pendl's function to create a decimal
'number from a large integer, using hex values
function largeInt2Dec(low, high)
    lowHex$ = right$("00000000" + dechex$(low), 8)
    highHex$ = right$("0000000" + dechex$(high), 8) 
    largeInt2Dec = hexdec(highHex$ + lowHex$)
end function


Home

Source Code

Utilities

Internet

Games

Graphics

Media Demos

Snippets

DLL's

API Resources

Freeware

LB 4 Companion

Mastering LB 3

LB Workshop

Game Workshop

Links

Index