Hello, I'm a writing a [ping] type of program, and I need to return the amount of time elapsed in miliseconds, anyone know how I can do this using the Timer function.. ?
------------------
------------------
#INCLUDE "WIN32API.INC" #IF NOT %DEF(%WINAPI) DECLARE FUNCTION QueryPerformanceCounter LIB "KERNEL32.DLL" _ ALIAS "QueryPerformanceCounter" _ (lpPerformanceCount AS QUAD) AS LONG DECLARE FUNCTION QueryPerformanceFrequency LIB "KERNEL32.DLL" _ ALIAS "QueryPerformanceFrequency" _ (lpFrequency AS QUAD) AS LONG #ENDIF FUNCTION WinUsec() AS DOUBLE DIM UsecFactor AS GLOBAL DOUBLE DIM TickF AS LOCAL QUAD DIM Ticks AS LOCAL QUAD IF ISFALSE UsecFactor THEN QueryPerformanceFrequency TickF UsecFactor=TickF/1000000 END IF QueryPerformanceCounter Ticks IF UsecFactor THEN FUNCTION = Ticks / UsecFactor END FUNCTION SUB DelayUsec(BYVAL Usec AS QUAD) DIM UsecFactor AS GLOBAL DOUBLE DIM Cproc AS GLOBAL DWORD DIM TickF AS LOCAL QUAD DIM Ticks AS LOCAL QUAD IF ISFALSE Cproc THEN Cproc=GetCurrentProcess SetPriorityClass Cproc,%REALTIME_PRIORITY_CLASS IF ISFALSE UsecFactor THEN QueryPerformanceFrequency TickF UsecFactor=TickF/1000000 END IF QueryPerformanceCounter Ticks Usec=Ticks+Usec*UsecFactor DO QueryPerformanceCounter Ticks LOOP UNTIL Ticks>Usec SetPriorityClass Cproc,%NORMAL_PRIORITY_CLASS END SUB
'Record your starttime In milliseconds Start = TimeGetTime() Tcp Open Port wPort At lserv As #hTcp TIMEOUT aTimeOut Do Tcp Recv #hTcp, 1600, buffer lpbuf = lpbuf + buffer Loop While Len(buffer) Tcp Close #hTcp lpbuf = Trim$(lpbuf, $LF) Replace $LF With $CRLF In lpbuf UTCTime = Trim$(lpbuf, $LF) Function = UTCTime Delay = TimeGetTime - Delay Stopp = TimeGetTime() 'Convert your Atomic time into a SYSTEMTIME structure ST 'FILETIME returns 100's of NANOSECONDS so you have to adjust 'Delay To reflect this resulotion Delay = (Stopp - Start)* 10000
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment