Skip navigation

További Invoke példák

MessageBox megjelnítése

;---ASM Hello World Win32 MessageBox

.386
.model flat, stdcall

include C:\masm32\include\kernel32.inc 
include C:\masm32\include\user32.inc

.data
    Titlestr    db  'Win32', 0
    Msg         db  'Hello World', 0

.code
    Main:
    
    INVOKE MessageBoxA, 0, offset titlestr, offset msg, 0
    INVOKE ExitProcess, eax
    
End Main

Idő megjelenítése

A következő program lekérdezi az aktuális időpontot, majd megjeleníti azt az általunk választott képernyő pozíción.


INCLUDE Irvine32.inc
.data

    sysTime SYSTEMTIME <>
    XYPos COORD <10,5>
    consoleHandle DWORD ?
    colonStr BYTE ":",0
    
.code

main PROC
    ; Get the standard output handle for the Win32 Console.
    INVOKE GetStdHandle, STD_OUTPUT_HANDLE
    mov consoleHandle,eax

    ; Set the cursor position and get the system time.
    INVOKE SetConsoleCursorPosition, consoleHandle, XYPos
    INVOKE GetLocalTime, ADDR sysTime

    ; Display the system time (hh:mm:ss).
    movzx eax,sysTime.wHour ; hours
    call WriteDec
    mov edx,OFFSET colonStr ; ":"
    call WriteString
    movzx eax,sysTime.wMinute ; minutes
    call WriteDec
    call WriteString
    movzx eax,sysTime.wSecond ; seconds
    call WriteDec
    call Crlf
    
    exit
    
main ENDP

END main