// 复制数据至剪切板
BOOL CopyToClipboard(const char* pszData, const int nDataLen)
{
if(::OpenClipboard(NULL))
{
::EmptyClipboard();
HGLOBAL clipbuffer;
char *buffer;
clipbuffer = ::GlobalAlloc(GMEM_DDESHARE, nDataLen+1);
buffer = (char *)::GlobalLock(clipbuffer);
strcpy(buffer, pszData);
::GlobalUnlock(clipbuffer);
::SetClipboardData(CF_TEXT, clipbuffer);
::CloseClipboard();
return TRUE;
}
return FALSE;
}
// 从剪切板中取得数据
BOOL GetTextFromClipboard()
{
if(::OpenClipboard(NULL))
{
//获得剪贴板数据
HGLOBAL hMem = GetClipboardData(CF_TEXT);
if(NULL != hMem)
{
char* lpStr = (char*)::GlobalLock(hMem);
if(NULL != lpStr)
{
//MessageBox(0, lpStr, "", 0);
::GlobalUnlock(hMem);
}
}
::CloseClipboard();
return TRUE;
}
return FALSE;
}
//
模拟Ctrl+V
keybd_event(VK_CONTROL,0,0,0);
keybd_event('V',0,0,0);
keybd_event('V',0,KEYEVENTF_KEYUP,0);
keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
++剪切板操作
最新推荐文章于 2023-06-25 14:58:46 发布