* This has resolution to 1 second:
ltMarker = GetGMTasDT()
inkey(2)
ltMarker2 = GetGMTasDT()
WAIT WINDOW ltMarker2-ltMarker
* An alternative that needs some work, but potentially has resolution to 100ms:
l64Marker = GetGMTasFT()
INKEY(2)
l64Marker2 = GetGMTasFT()
lnDiff = Subtract64BitStructures( l64Marker2, l64Marker )
WAIT WINDOW lnDiff
FUNCTION GetGMTasDT()
DECLARE INTEGER GetSystemTime IN WIN32API ;
STRING @ LPSYSTEMTIME_lpSystemTime
lpSYSTIME = REPLICATE(CHR(0),8*2)
GetSystemTime( @lpSysTime )
nYear = Buf2Word( SUBSTR( m.lpSysTime, 1, 2 ) )
nMonth = Buf2Word( SUBSTR( m.lpSysTime, 3, 2 ) )
nDay = Buf2Word( SUBSTR( m.lpSysTime, 7, 2 ) )
nHour = Buf2Word( SUBSTR( m.lpSysTime, 9, 2 ) )
nMinute = Buf2Word( SUBSTR( m.lpSysTime, 11, 2 ) )
nSec = Buf2Word( SUBSTR( m.lpSysTime, 13, 2 ) )
nThou = Buf2Word( SUBSTR( m.lpSysTime, 15, 2 ) )
RETURN DATETIME( nYear, nMonth, nDay, nHour, nMinute, nSec )
ENDFUNC
FUNCTION buf2word (lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
Asc(SUBSTR(lcBuffer, 2,1)) * 256
ENDFUNC
* The FILETIME structure is a 64-bit value representing the number
* of 100-nanosecond intervals since January 1, 1601 (UTC).
*, So, perhaps:
FUNCTION GetGMTasFT()
DECLARE INTEGER GetSystemTime IN WIN32API ;
STRING @ LPSYSTEMTIME_lpSystemTime
DECLARE INTEGER SystemTimeToFileTime IN kernel32;
STRING lpSYSTEMTIME,;
STRING @ FILETIME
lpSYSTIME = REPLICATE(CHR(0),8*2)
GetSystemTime( @lpSysTime )
lcBuffTime = REPLICATE(CHR(0),8)
SystemTimeToFileTime(m.lpSYSTIME,@lcBuffTime)
* This would let you manipulate lnBuffTime as a number,
* but VFP can't handle numbers this big!!
* lnBuffTime = BufTo64Bit( lcBuffTime )
RETURN lcBuffTime
ENDFUNC
* This doesn't work because VFP doesn't support enough places of precision:
*!* FUNCTION BufTo64Bit (lcBuffer)
*!* RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
*!* Asc(SUBSTR(lcBuffer, 2,1)) * 2^8 +;
*!* Asc(SUBSTR(lcBuffer, 3,1)) * 2^16 +;
*!* Asc(SUBSTR(lcBuffer, 4,1)) * 2^24 +;
*!* Asc(SUBSTR(lcBuffer, 5,1)) * 2^32 +;
*!* Asc(SUBSTR(lcBuffer, 6,1)) * 2^40 +;
*!* Asc(SUBSTR(lcBuffer, 7,1)) * 2^48 +;
*!* Asc(SUBSTR(lcBuffer, 8,1)) * 2^56
*!* ENDFUNC
FUNCTION Subtract64BitStructures( tc64_1, tc64_2 )
* Well, could someone figure out how to do 64-bit arithmatic in VFP?
* In VB, the recommendation is to store the value in a Currency type,
* which is a 64-bit integer with an implied 4 decimal places.
* This works in VB, if you multiply by 10000 before displaying the value.
* But can we do 64-bit in VFP?
RETURN 0
ENDFUNC