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);
}