News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

What time is it?

Started by frktons, August 30, 2010, 08:15:20 PM

Previous topic - Next topic

frktons

Quote from: cobold on August 30, 2010, 09:30:16 PM
Hi,

there is no mnemonic for Systemtime or time elapsed since system was started, but API:


include \masm32\include\masm32rt.inc

.data
   szfmt1  db "SystemTime is %02d:%02d",13,10,0
   szfmt2  db " LocalTime is %02d:%02d",13,10,0
   
.code
start:
   call main
   exit
; -------------------------------------------------------------------------
main proc

local stime     :SYSTEMTIME
local ltime     :SYSTEMTIME
local millisecs :DWORD

; is defined in windows.inc as follows:

; SYSTEMTIME STRUCT
;   wYear             WORD      ?
;   wMonth            WORD      ?      ; 1 = January, 2 = February, and so on
;   wDayOfWeek        WORD      ?      ; 0 = Sunday,  1 = Monday, and so on
;   wDay              WORD      ?
;   wHour             WORD      ?
;   wMinute           WORD      ?
;   wSecond           WORD      ?
;   wMilliseconds     WORD      ?
; SYSTEMTIME ENDS

; load SystemTime to STRUC stime
   invoke GetSystemTime,ADDR stime

; and print it
   invoke crt_printf,ADDR szfmt1,stime.wHour,stime.wMinute

   invoke GetLocalTime,ADDR ltime
   invoke crt_printf,ADDR szfmt2,ltime.wHour,ltime.wMinute

; get milliseconds since system start (return in EAX)
   invoke GetTickCount
   mov millisecs,eax
   print "Milliseconds since system boot: "
   print str$(millisecs),13,10

   ret
main endp

end start


I tried it again. This version shows the correct time on my machine, maybe because I'm using
ML V. 10 that do the needed conversion.
Mind is like a parachute. You know what to do in order to use it :-)