With that you can copy text to the clipboard
#include <windows.h>
#include <windowsx.h>
#include <stdalign.h>
BOOL WINAPI CopyToClipboard(HWND __hWnd,LPSTR __lpszText2Copy)
{
alignas(LPSTR) LPTSTR _lptstrCopy ;
alignas(HANDLE) HGLOBAL _hglbCopy ;
register int _cch, _iLen ;
_iLen = lstrlen(__lpszText2Copy) ;
if(_iLen == 0)
return (FALSE) ;
if(!OpenClipboard(__hWnd))
return (FALSE) ;
EmptyClipboard() ;
cch = _iLen + 256 ;
_hglbCopy = GlobalAlloc(GMEM_MOVEABLE,(_cch + 1) * sizeof(TCHAR)) ;
if(_hglbCopy == NULL)
{
CloseClipboard() ;
return (FALSE) ;
}
_lptstrCopy = GlobalLock(_hglbCopy) ;
memcpy(_lptstrCopy,__lpszText2Copy,_cch * sizeof(TCHAR)) ;
_lptstrCopy[_cch] = (TCHAR) 0 ;
GlobalUnlock(_hglbCopy) ;
SetClipboardData(CF_TEXT,_hglbCopy) ;
CloseClipboard() ;
return (TRUE) ;
}