GetLocalTime窗口显示本地时间

 

getlocaltime

源码:

        .386
        .model flat,stdcall
        option casemap:none
       
include        windows.inc
include        user32.inc
include        kernel32.inc

includelib    user32.lib
includelib    kernel32.lib

        .data       
SelString    dw    0,0

        .data?
stTimeInfo    SYSTEMTIME    <>
szBuffer    db        1024 dup(?)
ddYear        dd        ?
ddMonth        dd        ?
ddDay        dd        ?
ddHour        dd        ?
ddMinute    dd        ?
ddSecond    dd        ?
ddMilliseconds    dd        ?

        .const
WeekString    db        ‘日一二三四五六’,0
szMsgCaption    db        ‘what is the time’,0

szInfo        db        ‘%u年%u月%u日’,0dh,0ah,0dh,0ah,’星期%s’,0dh,0ah,0dh,0ah,’%u时%u分%u秒%u毫秒’,0dh,0ah,0

        .code
start:
    invoke    GetLocalTime,offset stTimeInfo;获取本地时间
    movzx    eax,stTimeInfo.wYear
    mov    ddYear,eax
    movzx    eax,stTimeInfo.wMonth
    mov    ddMonth,eax
   
    ;星期
    movzx    eax,stTimeInfo.wDayOfWeek
   
    .if    eax==0
        mov ax,word ptr WeekString
        mov  SelString,ax
    .elseif    eax==1
        mov ax,word ptr WeekString+2
        mov SelString,ax
    .elseif    eax==2
        mov ax,word ptr WeekString+4
        mov SelString,ax
    .elseif eax==3
        mov ax,word ptr WeekString+6
        mov SelString,ax
    .elseif eax==4
        mov ax,word ptr WeekString+8
        mov SelString,ax
    .elseif eax==5
        mov ax,word ptr WeekString+10
        mov SelString,ax
    .elseif eax==6
        mov ax,word ptr WeekString+12
        mov SelString,ax
    .endif
   
    movzx    eax,stTimeInfo.wDay
    mov    ddDay,eax
    movzx     eax,stTimeInfo.wHour
    mov    ddHour,eax
    movzx    eax,stTimeInfo.wMinute
    mov    ddMinute,eax
    movzx    eax,stTimeInfo.wSecond
    mov    ddSecond,eax
    movzx    eax,stTimeInfo.wMilliseconds
    mov    ddMilliseconds,eax
    invoke    wsprintf,addr szBuffer,addr szInfo,ddYear,ddMonth,ddDay,offset SelString,ddHour,ddMinute,ddSecond,ddMilliseconds
    invoke    MessageBox,NULL,addr szBuffer,addr szMsgCaption,MB_OK
    invoke    ExitProcess,NULL
   
    end start

唉,发现自己的基础性的东西还是太不扎实了,悲催~~