把文本放置到剪接板上: cstring source; //put your text in source if(openclipboard()) { hglobal clipbuffer; char * buffer; emptyclipboard(); clipbuffer = globalalloc(gmem_ddeshare, source.getlength()+1); buffer = (char*)globallock(clipbuffer); strcpy(buffer, lpcstr(source)); globalunlock(clipbuffer); setclipboarddata(cf_text,clipbuffer); closeclipboard(); }
从剪接板上获取文本: char * buffer; if(openclipboard()) { buffer = (char*)getclipboarddata(cf_text); //do something with buffer here //before it goes out of scope } closeclipboard();