The MASM Forum

General => The Campus => Topic started by: Anusha on March 15, 2013, 02:37:47 AM

Title: get system date
Post by: Anusha on March 15, 2013, 02:37:47 AM
Can anyone give the program code to get system date using masm

or the code for the same in assembly language
Title: Re: get system date
Post by: qWord on March 15, 2013, 02:56:48 AM
see GetSystemTime() (http://msdn.microsoft.com/en-us/library/windows/desktop/ms724390(v=vs.85).aspx):
include \masm32\include\masm32rt.inc
.code
main proc
LOCAl systime:SYSTEMTIME
;...
invoke GetSystemTime,ADDR systime
;...
exit

main endp
end main
Title: Re: get system date
Post by: herge on March 17, 2013, 12:52:22 AM

Hi anu_245:


http://masm32.com/board/index.php?topic=1300.msg16253#msg16253
(http://masm32.com/board/index.php?topic=1300.msg16253#msg16253)

We do the date and Time for Germany [above]


; REM SHOWTIME.ASM  Wednesday, September 24, 2008 2:30 PM
; by herge - Show System Date & Time
include \masm32\include\masm32rt.inc
.data
stm  SYSTEMTIME<>
    org stm; Must be eight words
wYear dw 0
wMonth dw 0
wToDay dw 0 ; Sunday 0 to Saturday 6
wDay    dw 0
wHour   dw 0
wMinute dw 0
wSecond dw 0
wKsecond dw 0
date_buf   db 50 dup (32)
time_buf   db 20 dup (32)
           db 0
dateformat  db " dddd, MMMM, dd, yyyy", 0
timeformat db "hh:mm:ss tt",0
.code
Start:
;  invoke   GetLocalTime, addr stm
;  invoke   GetDateFormat, 0, 0, \
;           ADDR stm, ADDR dateformat, ADDR date_buf, 50
   invoke   GetDateFormat, 0, 0, \
            0, ADDR dateformat, ADDR date_buf, 50
   mov   ecx, offset date_buf
   add   ecx, eax; add length returned by GetDateFormat
   mov   byte ptr [ecx-1], " " ;replace null with space
   invoke   GetTimeFormat, 0, 0, \
            0, ADDR timeformat, ecx, 20
   invoke   MessageBox, 0, addr date_buf, addr date_buf, MB_OK
   invoke ExitProcess, 0
end Start



Above your local Time.

Enjoy!