assembly - 如何在 DOSBox 中运行的汇编程序中将文本插入剪贴板?
问题描述
我在程序集中有一个包含字符串的 db 变量,如下所示:
STR_VAR db 'test$'
是否可以将此变量复制到剪贴板,这样当用户在另一个程序(例如 word)中按下 Ctrl+V 时,它会将文本粘贴到变量中。
编辑:重要信息:我正在使用 DOSBox 运行代码
解决方案
实际上有一个用于 DOS 的官方 API 用于访问主机的剪贴板,在 Windows 3.x 和 9x 中受支持。它在文章Q67675中有简要描述,以前在 Microsoft 的知识库中。
这是一个代码示例(NASM 语法):
org 0x100
mov ax, 0x1700 ; IdentifyWinOldApVersion
int 0x2f
cmp ax, 0x1700
jz error
mov ax, 0x1701 ; OpenClipboard
int 0x2f
test ax, ax
jz error
mov ax, 0x1709 ; ClipboardCompact
mov cx, STR_VAR.end - STR_VAR
xor si, si
int 0x2f
cmp dx, si
jb error
ja .fits
cmp cx, ax
jb error
.fits:
mov ax, 0x1703 ; SetClipboardData
mov dx, 7 ; CF_OEMTEXT
mov bx, STR_VAR
; ES and SI:CX already set up
int 0x2f
test ax, ax
jz error
mov ax, 0x1708 ; CloseClipboard
int 0x2f
mov ax, 0x4c00
int 0x21
error:
mov ax, 0x4c01
int 0x21
STR_VAR:
db 'test'
.end:
然而,我非常怀疑 vanilla DOSBox 是否真的支持这个 API(尽管它显然在 DOSBox-X 中得到支持,一个分支)。
推荐阅读
- java - 使用 Value("classpath:asterisks") 解释阅读资源
- java - StringTokenizer 上的意外行为
- javascript - 使用浏览器原生“后退”按钮关闭带有 JS 的模态窗口
- postgresql - 即使在使用我的 IP 地址更改了安全类之后,AWS 与 pgAdmin 的连接“超时已过期”错误
- html - 创建一个允许播放 2 个音频文件的音频元素
- c# - 使用 Microsoft.Azure.Management.ServiceBus 获取队列消息计数
- html - 如何在html中以较低的分辨率对齐表格
- java - GCP 支持来自 Cloud App Engine、Cloud Run 托管应用程序的所有 Content-Type:有什么方法可以简单地减少 Content-Type 传递的想法?
- redux - 在异步调用期间应该何时更新 redux 存储?
- python - 如何创建指示符列来指示数据框中先前条目的特定更改?