Retrieving Data from the Clipboard

The following code fragment shows how to open the clipboard, retrieve data in the requested format, copy the data to local memory, and close the clipboard:

    PSZ pszClipText, pszLocalText;

    if (WinOpenClipbrd(hab)) {
        if (pszClipText = (PSZ) WinQueryClipbrdData(hab, CF_TEXT)) {

            /* Copy text from the shared memory object to local memory. */
            while (*pszLocalText++ = *pszClipText++);
        }
        WinCloseClipbrd(hab);
    }


[Back: Putting Data on the Clipboard]
[Next: Viewing Data on the Clipboard]