On 26.07.2016 21:52, James Richters wrote: >> An alternative would be NtDelayExecution from unit jwanative. Its interval > argument is in multiples of 100ns >> and is essentially what Windows' Sleep() uses internally. >> Note: The first argument "Alertable" determines whether the function can be > interrupted by NtAlertThread >> (and whatever Windows API functions use that internally). > > This sounds like it would work, but I can't figure out how to use it. Do > you have an example? > I've tried just a quick test like this: > > uses > windows,jwanative; > Var > DelayInterval : PLarge_Integer; > Variable1:integer; > begin > DelayInterval:=1; > Variable1:=NtDelayExecution(true,DelayInterval); > end. > > It won't let me set DelayInterval with a constant, I get "Incompatible > Types: got "shortint" expected "Plarge_Integer" > I really don't undertand these variable types that it wants.
You need to declare a LargeInteger and pass the pointer to it to NtDelayExecution(). LargeInteger itself is declared as a case-record consisting of two 32-bit values (LowPart and HighPart) and a 64-bit value (QuadPart). Best is you assign your value to QuadPart, as that sets the record in one go. Oh and I forgot to mention that you need to use a negative value for relative sleeps (otherwise you'll wait until that time from the system start on has passed, so "1" would be a no-op basically ;) ) For an example see the implementation of Sleep in the SysUtils unit of the NativeNT target: rtl/nativent/sysutils.pp (near the end of the file) Regards, Sven _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal