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.
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.
-sloat ok i done that. but after the wsprintf call the out buffer is empty. :( thanks anyway. more help please ... skud.
Try the follwing code (it worked for me):
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
.data timestruct SYSTEMTIME <> buffer db 64 dup (0) rawinfo db "Hour is %x",0 .code start: 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
top stuff mirno. works like a gem. skud.