Results 1 to 5 of 5

Thread: Clipboard

  1. #1
    Guest

    Post

    How do i copy a string to the clipboard?

  2. #2
    Guest
    Anyone?

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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;
    }
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    What is argc?

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width