[try Beta version]
Not logged in

 
OS Information

Jul 20, 2015 at 11:10am
Hi, I have created an MFC dialog based application that reads CString data and copies that data to the clipboard so that the data can easily be transferred onto word files.
I have been told that the operating system the computer is running on needs to be copied to the clipboard as well. Any help on this would be greatly appreciated.

This is the code I have already.

void CBugsDlg::OnBnClickedBtnCopy()
{

CVersionTranslatomatic ver(::GetDesktopWindow());
CString version = ver.GetMajorMinorVersionString() + " " + ver.GetVersionType() + " " + ver.GetBuildNumber() + " " + ver.GetServicePack();

HGLOBAL hglbCopy;


if( OpenClipboard()){
EmptyClipboard();
wchar_t *wcBuffer = 0;
hglbCopy = GlobalAlloc(GMEM_MOVEABLE,(version.GetLength() + 1)*sizeof(wchar_t));
wcBuffer = (wchar_t*)GlobalLock(hglbCopy);
lstrcpy(wcBuffer, version);
GlobalUnlock(hglbCopy);
SetClipboardData(CF_UNICODETEXT, hglbCopy);
CloseClipboard();
}



}
Last edited on Jul 22, 2015 at 2:01pm
Topic archived. No new replies allowed.