下载
关键代码
#include <curl/curl.h>
std::wstring get_current_clipboard(HWND hwnd)
{
if (!OpenClipboard(hwnd)) {
return L"";
}
HANDLE h = GetClipboardData(CF_UNICODETEXT);
if (!h) {
CloseClipboard();
return L"";
}
wchar_t* data = (wchar_t*)GlobalLock(h);
if (!data) {
CloseClipboard();
return L"";
}
std::wstring result = data;
GlobalUnlock(h);
CloseClipboard();
return result;
}
void put_in_clipboard(HWND hwnd, const std::wstring& data)
{
if (!OpenClipboard(hwnd)) {
return;
}
EmptyClipboard();
HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (data.length() + 1) * sizeo