void SetClipboardString(CString &str)
{
HANDLE hClip;
char *pBuf;
if (!::OpenClipboard(NULL)) {
::EmptyClipboard();
hClip=::GlobalAlloc(GMEM_MOVEABLE,str.GetLength()+1);
pBuf=(char *)::GlobalLock(hClip);
strcpy(pBuf,str);
::GlobalUnlock(hClip);
::SetClipboardData(CF_TEXT,hClip);
::CloseClipboard();
}
}
CString GetClipboardString()
{
CString str;
HANDLE hClip;
char *pBuf;
if(::OpenClipboard(NULL))
{
if(::IsClipboardFormatAvailable(CF_TEXT))
{
hClip=::GetClipboardData(CF_TEXT);
pBuf=(char *)::GlobalLock(hClip);
str.Format("%s", pBuf);
::GlobalUnlock(hClip);
::CloseClipboard();
}
}
return str;
}
{
HANDLE hClip;
char *pBuf;
if (!::OpenClipboard(NULL)) {
::EmptyClipboard();
hClip=::GlobalAlloc(GMEM_MOVEABLE,str.GetLength()+1);
pBuf=(char *)::GlobalLock(hClip);
strcpy(pBuf,str);
::GlobalUnlock(hClip);
::SetClipboardData(CF_TEXT,hClip);
::CloseClipboard();
}
}
CString GetClipboardString()
{
CString str;
HANDLE hClip;
char *pBuf;
if(::OpenClipboard(NULL))
{
if(::IsClipboardFormatAvailable(CF_TEXT))
{
hClip=::GetClipboardData(CF_TEXT);
pBuf=(char *)::GlobalLock(hClip);
str.Format("%s", pBuf);
::GlobalUnlock(hClip);
::CloseClipboard();
}
}
return str;
}