I use key word "GetDateFormat" to Search.

I found this example.

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
szTime db "00:00:00", 0 ; time mask

.code
start:
invoke GetTimeFormat,0,TIME_FORCE24HOURFORMAT,0,0,
addr szTime,9 ; get current time
invoke MessageBox, 0, addr szTime, 0, 0
invoke ExitProcess,NULL
end start

but it just "00:00:00"

How to get time & date and show it ?
Posted on 2002-07-09 23:09:32 by fox
You are getting your default time (that you initialised your buffer to), because the buffer you have supplied to the API is too small. You should call the function twice: the first time with a zero length buffer, this will fail, and the API will return the required buffer size in eax. Then you allocate a buffer of the same size as indicated by eax. Then you recall the function with the new buffer, the API will happily fill it.
Posted on 2002-07-10 00:09:55 by sluggy
That code works for me.
Posted on 2002-07-10 01:03:28 by WinCC
thanks.

Now I get it.

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
stm SYSTEMTIME<>
dateformat db "dd:MM:yyyy",0
buffer db 100 dup (0)

.code
start:
invoke GetLocalTime, addr stm
invoke GetDateFormat, LOCALE_USER_DEFAULT, NULL, \
addr stm,addr dateformat, addr buffer, sizeof buffer
invoke MessageBox, 0, addr buffer, NULL, MB_OK
invoke ExitProcess,NULL
end start
Posted on 2002-07-10 04:21:27 by fox
Another question!

How to add or sub wYear,wMonth,wDay?

.code
start:
invoke GetLocalTime, addr stm
ASSUME edi: PTR SYSTEMTIME ;?
mov edi,offset stm ;?
mov ax,.wYear ;?
sub ax,1 ;?
mov .wYear,ax ;?
invoke MessageBox, 0, addr stm.wYear, NULL, MB_OK ;?
Posted on 2002-07-10 22:13:18 by fox
How about this:

[size=12]

.code

start:

invoke GetLocalTime, addr stm
ASSUME edi :PTR SYSTEMTIME
lea edi, stm
sub [edi].wYear, 1
invoke MessageBox, 0, addr stm.wYear, NULL, MB_OK
assume edi :nothing

[/size]
Posted on 2002-07-10 23:10:44 by sluggy
wYear is not a string, I suggest you don't push it for MessageBox.
Posted on 2002-07-10 23:12:42 by comrade
wYear is not a string, I suggest you don't push it for MessageBox.
Oops, i forgot about that too. I obviously spend too much time in HLLs that implicitly do the conversion for you :/
Posted on 2002-07-10 23:59:57 by sluggy