The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: xwwwx on November 12, 2011, 09:29:50 PM

Title: Comparing result from GetDateFormat
Post by: xwwwx on November 12, 2011, 09:29:50 PM
I am retrieving the day of the month with GetDateFormat, here's the code:

.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\kernel32.lib
includelib \masm32\lib\user32.lib
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib

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

.data
szDFormat db "dd", 0Dh, 0Ah, 0

.data?
stCurTime SYSTEMTIME <>
szDate db 5 dup (?)

.code
    _ep:
   
    invoke GetLocalTime, addr stCurTime
   
    invoke GetDateFormat, LOCALE_USER_DEFAULT, NULL, addr stCurTime, addr szDFormat, addr szDate, 5
   
    invoke MessageBox, NULL, addr szDate, NULL, MB_OK

    invoke ExitProcess,0

end _ep


It works fine and the msgbox show the current day, but now I want to compare that day with another hardcoded value, for example: "if szDate == 12 || szDate == 24 do something".

I have tried:
.if szDate == 12
  msgbox here
.endif


But didn't work. Also tried:
date db "12", 00h
...
invoke lstrcmp, addr szDate, addr date
.if eax == 0
   msgbox here
.endif


But eax is never 0, how can I compare the result of GetDateFormat with a hardcoded value?
Title: Re: Comparing result from GetDateFormat
Post by: xwwwx on November 12, 2011, 09:41:28 PM
My bad, I was entering the wrong size for the 4th param.
Title: Re: Comparing result from GetDateFormat
Post by: jj2007 on November 12, 2011, 11:27:27 PM
Welcome to the Forum :U

That was enough proof that you are not a bot :green2
Title: Re: Comparing result from GetDateFormat
Post by: dedndave on November 12, 2011, 11:57:06 PM
i think you want to compare strings
be sure you force the right format   :P

here is what i use, as i always wanted 24-hour format hh:mm:ss
        INVOKE  GetTimeFormat,LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT or TIME_NOTIMEMARKER,NULL,NULL,eax,32

welcome to the forum   :U