Oops, I read your question too fast and thought you asked for a way to get text from the clipboard
Here we go:
Code:
BOOL SetClipboardText(LPCTSTR lpszText, UINT uBuff)
{
HGLOBAL hgText = NULL;
LPTSTR lpszCopy = NULL;
// First open the clipboard
if(!::OpenClipboard(NULL))
return FALSE;
// Empty the clipboard, and make us the owner
if(!::EmptyClipboard())
{
::CloseClipboard();
return FALSE;
}
hgText = GlobalAlloc(GMEM_DDESHARE, (uBuff+1) * sizeof(TCHAR));
if (hgText != NULL)
{
// Lock the handle and copy the text to the buffer.
lpszCopy = (char*)GlobalLock(hgText);
memcpy(lpszCopy, lpszText, uBuff * sizeof(TCHAR));
lpszCopy[uBuff] = (TCHAR) 0;
GlobalUnlock(hgText);
// Set the clipboard text
if(!::SetClipboardData(CF_TEXT,hgText))
{
::CloseClipboard();
return FALSE;
}
}
::CloseClipboard();
return TRUE;
}