On Tue, 22 Feb 2011 14:05:33 +0100 (CET), Michael Van Canneyt <[email protected]> wrote:
>> After googling a bit I have come up with the following, which is a >> variation of a delay function that I created years ago in Delphi to >> enable me to output pulses that are timed to milliseconds. >> The delay is now converted to a time retrieval function: >> >> function TForm1.GetMillisecondTime: Int64; >> var >> Freq, >> Ts: Int64; >> begin >> QueryPerformanceCounter(Ts); >> QueryPerformanceFrequency(Freq); >> if (Ts = 0) or (Freq = 0) then exit; >> Freq := Freq div 1000; >> Result := TS div Freq; >> end; >> >> When I try this in Lazarus I get an "Identifier not found" error (not >> surprising). >> What should I do in order to get this to compile? >> Any suitable unit to add to the uses clause? > >If you are on windows: add the windows unit. > >If you are on another platform: these functions simply do not exist on other >platforms. > Thanks, I have now tested it (on Windows) and found that although the QueryPerformanceCounter gives more resolution it is also drifting compared to real time (77 ms in 30 s) making it rather unusable... It would be good for a highres timer but not for keeping track of time over longer periods. I took steps to make the calculations less vulnerable to resolution issues by first snatching a counter value and then for all subsequent calculations I subtracted this from what I read before switching to double precision arithmetic. Have to look elsewhere. -- Bo Berglund Developer in Sweden -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
