如何检索复制的文本(使用 CTRL + C 命令)
How to retrive text that was copied (with the CTRL + C command)
我有一个用 C++ 编写的 Windows 应用程序。我想添加一个粘贴选项,以便应用程序可以根据请求检索用户之前复制的任何文本(即使用 control-C 命令)。
有办法吗?
您需要使用函数 OpenClipboard()
、GetClipboardData()
和 CloseClipboard()
。
来自 MSDN:
Pasting Information from the Clipboard
Open the clipboard by calling the OpenClipboard function.
Determine which of the available clipboard formats to retrieve.
Retrieve the handle to the data in the selected format by calling the GetClipboardData function.
Insert a copy of the data into the document.
The handle returned by GetClipboardData is still owned by the clipboard, so an application must not free it or leave it locked.
Close the clipboard by calling the CloseClipboard function.
我有一个用 C++ 编写的 Windows 应用程序。我想添加一个粘贴选项,以便应用程序可以根据请求检索用户之前复制的任何文本(即使用 control-C 命令)。
有办法吗?
您需要使用函数 OpenClipboard()
、GetClipboardData()
和 CloseClipboard()
。
来自 MSDN:
Pasting Information from the Clipboard
Open the clipboard by calling the OpenClipboard function.
Determine which of the available clipboard formats to retrieve.
Retrieve the handle to the data in the selected format by calling the GetClipboardData function.
Insert a copy of the data into the document.
The handle returned by GetClipboardData is still owned by the clipboard, so an application must not free it or leave it locked.
Close the clipboard by calling the CloseClipboard function.