1

I want a program to do X task twice a month. So I though about getting the current day as number so I could do something like if day == 1 or 15 then do X

Does someone has a simple masm example to get the current day as a number?

I am looking for code simplicity so I can understand what it does, maybe there's some win api I could call.

1 Answer 1

2
.386
.model flat, stdcall
.stack 4096
option casemap :none

include masm32.inc
include kernel32.inc
include macros.asm

GetLocalTime PROTO :DWORD
.data
LPSYSTEMTIME STRUCT
    wYear       WORD ?
    wMonth      WORD ?
    wDayOfWeek  WORD ?
    wDay        WORD ?
    wHour       WORD ?
    wMinute     WORD ?
    wSecond     WORD ?
    wMilliseconds WORD ?
LPSYSTEMTIME ENDS

localTime LPSYSTEMTIME <>
.code
main PROC   

 invoke GetLocalTime, ADDR localTime    
 invoke ExitProcess,eax 
main ENDP
END main

You can pull the current day of the week or month from the localTime STRUCT. Visit my blog Set up visual studio 10 for masm32 programming for details on how to setup visual studio.

2
  • And pull the date out just using the struct. localTime.wDate.. Additionally you don't have to define the proto, nor the struct cause they are already in kernel32
    – f2lollpll
    Commented Jan 22, 2012 at 12:56
  • from this line:GetLocalTime PROTO :DWORD error A2119: language type must be specified why? Commented Nov 22, 2012 at 22:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.