I am writing a c++ program for windows using the API. My program needs to be able to get some text from the clipboard, import it to the program's scope as a string, and do work on the string.
[what I have tried]
Both of these printed/returned zero, which, msdn says, means the functions failed.Code:cout << GetClipboardData(CF_TEXT) << endl; cout << GetClipboardData(CF_UNICODETEXT) << endl;
I found the MSDN documentation wanting...an example would have been nice.
Even if the above functions returned a non-zero result, I am not sure how I would use the returned data handle to get the data as a string.
I could post a paste message to a temporary text file, then import the text using fstream, but this is rather a backwards way of going about it.
I am hoping someone would please shed some light on how to get text from the clipboard as a string into my c++ program.