Copying data to the Clipboard
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;
}
Getting data from the Clipboard
BOOL Gettextfromclipboard ()
{
If (:: OpenClipboard (NULL))
{
Get Clipboard data
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;
}
From:https://zhidao.baidu.com/question/647698977954822045.html
"go" how does C + + read and write the contents of the Windows clipboard? for example, automatically copy a string.