+ Reply to Thread
Results 1 to 3 of 3

Thread: How to get text data from clipboard using WIN32?

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    43

    How to get text data from clipboard using WIN32?

    Hi,

    I want to read clipboard data and display it on my application.

    How can I achieve this?

    Thanks.

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    37
    GetClipboardData WIN32 API is useful in such case.


    Example:

    Code:
    CString GetClipboardData()
    {
    	CString strClipboardData ;
    
    	if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL))
    	{
    		HGLOBAL hGlobal = GetClipboardData(CF_TEXT) ;
    		if (hGlobal != NULL) 
            { 
                LPTSTR lpszData = (LPTSTR) GlobalLock(hGlobal) ;
                if (lpszData != NULL) 
                { 
                    strClipboardData = lpszData ;
                    GlobalUnlock(hGlobal) ;
                }
            }
            CloseClipboard() ;
    	}
    
    	return strClipboardData ;
    }

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    43
    Great.

    Thanks

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts