Code:BOOL GetClipboardText(LPTSTR buff, UINT iBuffSize) { HANDLE hClip; char* pszClipboard; if(OpenClipboard(NULL)) // Open the clipboard so we can read its contents { hClip = GetClipboardData(CF_TEXT); // Get a handle to the clipboad contents if(hClip == NULL) { CloseClipboard(); return FALSE; } pszClipboard = (char*)GlobalLock(hClip); // Point pClipboard to the clipboard contents if(!pszClipboard) { GlobalUnlock(hClip); return FALSE; } strncpy(buff,pszClipboard,iBuffSize); // Copy the contents to a local variable buff[iBuffSize-1] = 0; GlobalUnlock(hClip); // Release the lock on the clipboard contents CloseClipboard(); // Close the clipboard. } else { return FALSE; } return TRUE; }