|
-
Jan 17th, 2001, 02:39 PM
#1
How do i copy a string to the clipboard?
-
Jan 18th, 2001, 02:58 PM
#2
-
Jan 18th, 2001, 03:39 PM
#3
Frenzied Member
This will copy the string "vlatko" to the clipboard:
Code:
#include <windows.h>
int main(int argc, char* argv[])
{
LPTSTR lptstrCopy;
OpenClipboard(NULL);
EmptyClipboard();
HGLOBAL txt = GlobalAlloc(GMEM_DDESHARE,(strlen("vlatko") +1 ) * sizeof(TCHAR));
lptstrCopy = (char*)GlobalLock(txt);
memcpy(lptstrCopy,"vlatko",(strlen("vlatko")) * sizeof(TCHAR));
lptstrCopy[strlen("vlatko")] = (TCHAR) 0;
GlobalUnlock(txt);
SetClipboardData(CF_TEXT,txt);
CloseClipboard();
return 0;
}
-
Jan 18th, 2001, 04:53 PM
#4
Addicted Member
-
Jan 18th, 2001, 05:20 PM
#5
Frenzied Member
It is an argument of the main function. It doesn't do nothing in this case. argc contains the nuber of parameters passed to the program.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|