Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Printing to clipboard

Name: Anonymous 2012-03-20 12:40

Greetings,

I'm looking to print/export text to the clipboard in a C++ program and this way works just fine for 1 or more lines or text:

        HGLOBAL hText;
        char *pText;
        hText = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 100);
        pText = (char*)GlobalLock(hText);
        strcpy(pText, "Example text line 1\r\nExample text line 2);
        GlobalUnlock(hText);

        OpenClipboard(NULL);
        EmptyClipboard();
        SetClipboardData(CF_TEXT, hText);
        CloseClipboard();

The problem is I've got some variables, and despite a lot of effort I cannot figure out how to print the text script + the variables inside it.

TL;DR: How do I into text + variables to clipboard in C++?

Name: Anonymous 2012-03-20 14:00

Would sprintf work if I crammed the variables into a string, then using the name of that string in strcpy(pText, stringName);?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List