I have an ASCII string (A null terminated char array) in a console app.
all I want to do is make it so my app will put this string into the "global clipboard" so that after running it, I can ctrl+v in any standard app (in this case, visual studio) and my string will be pasted!
how do I do this?
I have done:
void SetClipboardText(char* txt)
{
if(!OpenClipboard(NULL))
{
__asm int 3;
}
int l = PIstrlen(txt);
HLOCAL la = GlobalAlloc(LMEM_MOVEABLE,l+1);
void* dest = GlobalLock(la);
PImemcpy(dest,txt,l+1);
GlobalUnlock(la);
if(!SetClipboardData(CF_OEMTEXT,la))
{
__asm int 3;
}
CloseClipboard();
}
I have tried CF_TEXT, CF_OEMTEXT, CF_UNICODE, I have tried NULL and GetDesktopWindow() when opening the clipboard
nothing seems to work. Edit: the above code always 'works' it never errors, it just never does what I want!