How to use GetClipboardData(CF_TEXT); without calling and use process id of this in C++?
and which libary does GetClipboardData(CF_TEXT) belong to?
How to use GetClipboardData(CF_TEXT); without calling and use process id of this in C++?
Share
GetClipboardData()is a Win32 API function.The handle returned by
GetClipboardData()must be first locked withGlobalLock(), then you can retrieve thechar*pointer of the ANSI text in the clipboard (note that if you want to retrieve Unicode text, you should use theCF_UNICODETEXTformat).A sample code to retrieve the text from the clipboard and store it in a convenient
std::stringclass instance follows (error management omitted for simplicity):You can use C++ RAII pattern and manage error conditions using exceptions, something like this: