ok. i have got the local time and i want to format it using wsprintf. this is my code and i can see no reason why it is not producing the outcome i want. .data timestruct SYSTEMTIME <> rawinfo db "Hour is %x",13,10 .data? hour WORD ? .code invoke GetLocalTime,ADDR timestruct mov cx,timestruct.wHour mov hour,cx invoke wsprintf,ADDR out,ADDR rawinfo,ADDR hour ----------------------------------------------->>>>>>>>> this is putting "4208608" in the string. it assembles OK. if you have any idea why this is happening please let me know. thanks. skud.
Posted on 2001-05-09 18:01:00 by skud
it's printing the address of the 'hour' variable because you're using the ADDR type modifier. just pass the variable without ADDR and it should be fine.
Posted on 2001-05-10 00:52:00 by Sloat
-sloat ok i done that. but after the wsprintf call the out buffer is empty. :( thanks anyway. more help please ... skud.
Posted on 2001-05-10 11:37:00 by skud
Try the follwing code (it worked for me):

timestruct  SYSTEMTIME <>
buffer      db 64 dup (0)
rawinfo     db "Hour is %x",0

  invoke GetLocalTime,ADDR timestruct
  xor ecx, ecx
  mov cx, timestruct.wHour

  invoke wsprintf, ADDR buffer, ADDR rawinfo, ecx
  invoke MessageBox, NULL, ADDR buffer, NULL, MB_OK
  invoke ExitProcess, NULL
end start
I didn't use the variable "hour", but if you want to store it for later, I think wsprintf wants a DWORD (hence the xor ecx, ecx - mov cx, timestruct.wHour). Also, you may have been having a problem with using "out" as a variable name, as it is a reserved word (there is an "out" instruction). Mirno
Posted on 2001-05-10 12:14:00 by Mirno
top stuff mirno. works like a gem. skud.
Posted on 2001-05-10 12:26:00 by skud