Thursday, May 30, 2013

C Programming: Copy to clipboard

#include <stdio.h>
#include <windows.h>
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
int GetClipboardSize()
{
  OpenClipboard(NULL) ;                          // Obtain clipboard
  HGLOBAL handle = GetClipboardData (CF_TEXT) ;  // get handle to data
  CloseClipboard() ;                             // Close clipboard
  return GlobalSize( handle ) ;                  // return size of data
}
void GetClipboardText( TCHAR * buffer )
{
  OpenClipboard(NULL) ;                          // Obtain clipboard 
  HGLOBAL handle = GetClipboardData (CF_TEXT) ;  // get handle to data 
  char* szClipboard = (char*)GlobalLock(handle); // lock data
  lstrcpy( buffer, szClipboard ) ;               // copy clipboard text
  GlobalUnlock (handle) ;                        // unlock data
  CloseClipboard () ;                            // close data
}
int main()
{
  // Allocate enough memory to save text in clipboard.
  char * szClipboardText = new char[ GetClipboardSize() + 1 ] ;
  // Get the clipboard text.
  GetClipboardText( szClipboardText ) ;
  // Print clipboard text.
  printf( "Clipboard Text: \"%s\"", szClipboardText );
cout << endl;
  // Delete the memory.
  delete[] szClipboardText ;
  getchar();
}

Result:


1 comment:

  1. C Programming: Copy To Clipboard ~ Everyday-Geeks >>>>> Download Now

    >>>>> Download Full

    C Programming: Copy To Clipboard ~ Everyday-Geeks >>>>> Download LINK

    >>>>> Download Now

    C Programming: Copy To Clipboard ~ Everyday-Geeks >>>>> Download Full

    >>>>> Download LINK nC

    ReplyDelete