Hi, my second Post ;-

I've alittle Problem:
My program does something like haning up with the line:

invoke GetLocalTime, Date

without these line it works propably.
What do I wrong?
Posted on 2002-01-20 07:28:17 by TCT
TCT,



// from PlatformSDK:

VOID GetLocalTime(
LPSYSTEMTIME lpSystemTime // system time
);


GetLocalTime requires a pointer to a SYSTEMTIME structure.
You need to declare it in you .data? section and pass the
address of the structure to the API call:



[...]
.data?
st SYSTEMTIME <?>
[...]
.code
[...]
invoke GetLocalTime, addr st
[...]


That should work. But I personally prefer the follwing way to get the current time (for getting the date, look up GetDateFormat):



[...]
.data
szTime db "00:00:00", 0 ; time mask
[...]
.code
[...]
invoke GetTimeFormat, 0, TIME_FORCE24HOURFORMAT, 0, 0, \
addr szTime, 9 ; get current time
invoke MessageBox, 0, addr szTime, 0, 0
[...]


Hope this helps!

bAZiK
Posted on 2002-01-20 07:49:03 by bazik
Hi bAZiK,

Tried your code but can't get the time to show:

-----------------------------------------------

.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

------------------------------------------------
Posted on 2002-01-20 08:42:46 by gscundiff
gscundiff,
really? I compiled the code you posted, and it works fine :confused:
Posted on 2002-01-20 09:17:01 by bazik
Nice, it works.
Thanks.

But: The other way is really confusing me. I've thought that a string variable already is an address.
What is saved in st after


.data?
st SYSTEMTIME <?>

I've thought it is the adress of wYear but now I think it's the value of wYear.
Correct?
Posted on 2002-01-20 12:22:13 by TCT
TCT,

Access the different members of the SYSTEMTIME
structure by doing the following, for example:


[...]
.data?
st SYSTEMTIME <?>
month_now dw ?
[...]
.code
[...]
invoke GetLocalTime, addr st
mov ax, st.wYear
mov month_now, st.wMonth

[...]

farrier
Posted on 2002-01-20 17:27:41 by farrier
My problem was that I thought after


.data?
st SYSTEMTIME <?>

, st would contain the adress of my sytem time structure.
But it seems like the following lines of the win32 programmer's reference

VOID GetLocalTime(

LPSYSTEMTIME lpSystemTime // address of system time structure
);

means that it needs the adress of tfhe adress of the first byte of the SYSTEMTIME structure.
Posted on 2002-01-21 03:48:29 by TCT


SYSTEMTIME is defined like this:

SYSTEMTIME STRUCT
wYear WORD ?
wMonth WORD ?
wDayOfWeek WORD ?
wDay WORD ?
wHour WORD ?
wMinute WORD ?
wSecond WORD ?
wMilliseconds WORD ?
SYSTEMTIME ENDS

.DATA? is a placeholder for uninitialized data... that
means all variables and stuff you define in this section
are not present in the compiled output... this data is
allocated at runtime... uninitialized data means that
you can not assign values in your source...

so if you write "st SYSTEMTIME <?>" 8 uninitialized
words are allocated if you run the executable...

if you want the ADRESS of st there are lots of ways to
do this... for example:

mov eax, offset st
mov word ptr [eax], 2002
mov word ptr [eax+2], 01
or

ASSUME edi: PTR SYSTEMTIME
mov edi,offset st
mov [edi].wYear,2002
mov [edi].wMonth,01
Posted on 2002-01-21 05:56:48 by mob