CString source;
source.Format("%s, %s, %s",
LogonByName.szMD5Pass,
LogonByName.TML_SN,
LogonByName.szMathineCode
);
if(OpenClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
source.Format("%s, %s, %s",
LogonByName.szMD5Pass,
LogonByName.TML_SN,
LogonByName.szMathineCode
);
if(OpenClipboard())
{
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(source));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT,clipbuffer);
CloseClipboard();
}
windows的API函数的话OpenClipboard的参数是窗口句柄AfxGetMainWnd()->GetSafeHwnd()使用if(::OpenClipboard(AfxGetMainWnd()->GetSafeHwnd())),如果是CWnd::OpenClipboard的话不需要任何参数。