Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <string.h>
  6. __cdecl
  7. main (c, v)
  8. int c;
  9. char *v[];
  10. {
  11. HANDLE hMem;
  12. LPSTR lpMem;
  13. FILE *OutputFile;
  14. if (c <= 1) {
  15. OutputFile = stdout;
  16. }
  17. else
  18. if (c == 2) {
  19. OutputFile = fopen( v[1], "w" );
  20. if (OutputFile == NULL) {
  21. fprintf( stderr, "DUMPCLIP: unable to open destination file '%s' (%u)\n", v[1], GetLastError() );
  22. return 1;
  23. }
  24. }
  25. if (!OpenClipboard( NULL )) {
  26. fprintf( stderr, "DUMPCLIP: unable to open clipboard (%u)\n", GetLastError() );
  27. return 1;
  28. }
  29. _setmode( _fileno( OutputFile ), _O_BINARY );
  30. hMem = GetClipboardData( CF_OEMTEXT );
  31. if (hMem != NULL) {
  32. lpMem = GlobalLock( hMem );
  33. if (lpMem) {
  34. fprintf( OutputFile, "%s", lpMem );
  35. }
  36. GlobalUnlock( hMem );
  37. }
  38. else {
  39. fprintf( stderr, "DUMPCLIP: unable to get clipboard data as text (%u)\n", GetLastError() );
  40. }
  41. CloseClipboard();
  42. return( 0 );
  43. }