well, i've had a look as MSDN, and it's really not a help.
if anyone could post a quick example of the code that will *work* i'll love you forever.
Printable View
well, i've had a look as MSDN, and it's really not a help.
if anyone could post a quick example of the code that will *work* i'll love you forever.
Assuming you are interested in text......run this and then paste into any program (MSWord, notepad.....etc)....
Code:#include <windows.h>
#include <string.h>
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HANDLE hData;//For the data to send to the clipboard
char szData[] = "Hello World (from the clipboard!!)",//phrase
*ptrData = NULL;//pointer to allow char copying
int nStrLen = strlen(szData);//length of phrase
hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
nStrLen + 1);//get handle to memory to hold phrase
ptrData = (char*)GlobalLock(hData);//get pointer from handle
memcpy(ptrData,szData,nStrLen + 1);//copy over the phrase
GlobalUnlock(hData);//free the handle
OpenClipboard(NULL);//allow you to work with clipboard
EmptyClipboard();//clear previous contents
SetClipboardData(CF_TEXT,hData);//set our data
CloseClipboard();//finished!!
return 0;
}
Oh........and there is no need to "love me forever"......
*praises Fordy*
love you man :)