📜  使用程序集访问剪贴板 api - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:37.289000             🧑  作者: Mango

代码示例1
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