access clipboard api with assembly code example
Example: access clipboard api with assembly
IDEAL
MODEL small
STACK 100h
DATASEG
STR_VAR DB 'test',0
CODESEG
start:
mov ax, @data
mov ds, ax
mov ax, 1700h ; IdentifyWinOldApVersion
int 2fh
cmp ax, 1700h
jz error_2
mov ax, 1701h ; OpenClipboard
int 2fh
test ax, ax
jz error_2
mov ax, 1709h ; ClipboardCompact
mov cx, 5 ; STR_VAR.end - STR_VAR
xor si, si
int 2fh
;cmp dx, si
;jb error_2
;ja fits
cmp dx, 0
jne fits
cmp ax, 0
je error_2
jmp fits
cmp cx, ax
jb error_2
fits:
mov ax, 1703h ; SetClipboardData
mov dx, 7 ; CF_OEMTEXT
mov bx, offset STR_VAR
; ES and SI:CX already set up
push ds
pop es
int 2fh
test ax, ax
jz error_2
mov ax, 1708h ; CloseClipboard
int 2fh
mov ax, 4c00h
int 21
error_2:
mov ax, 4c01h
int 21
exit:
mov ax, 4c00h
int 21h
END start