I am working on a C++ program that allows you to paste URLs into YouTube comments/posts on forums where URLs are forbidden. It works by pasting the modified (post-safe!) URL onto your clipboard. I ran into an invalid handle error (error code 6) upon trying to SetClipboardData(CF_TEXT, (void*)modifiedText.c_str()); Has anyone else on here run into the same/similar issues, and how did they solve it? //I was using a plain old HANDLE to store modifiedText.c_str(). Will I have to upgrade to HGLOBAL, or something?
I also know that OpenClipboard(HWND); takes, as its parameter, a handle to the window that is using the clipboard, but I wish to place the data on the clipboard for the browser (whatever they are running), and possibly this program that I am making, to use the clipboard. I was thinking of implementing some version of the code snippet found here: http://www.cplusplus.com/forum/beginner/33250/ , but have no idea as to how hWnd is defined. //I try typing that into my Code::Blocks IDE and it doesn't know what the hell I am talking about. I know that typeid(hWnd).name() == "HWND"; (or some child of it), but is it being initialized to the current window (hopefully, not 0....) upon declaration?
I understand the code snippet now, and have used it. This one that is: http://www.cplusplus.com/forum/beginner/14349/ . Thank you, helios for writing that; although I have improved it by exploiting the fact that some of those functions are boolean, or return 0 upon failure. I also made my function boolean. I would like to learn about the multithreading that went on there and why it was even necessary.