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.

113 lines
3.4 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. char achLine[17];
  4. void Dump( PBYTE pb, DWORD cb ) {
  5. DWORD i, j;
  6. for( i = 0; i < cb; i += 16 ) {
  7. printf( "%04X ", (int)i );
  8. FillMemory( achLine, sizeof(achLine), 0);
  9. for( j = 0; j < 16; j++ ) {
  10. BYTE b;
  11. if (i+j >= cb) {
  12. break;
  13. }
  14. printf( "%02X ", (b = pb[i+j]) );
  15. achLine[j] = b >= ' ' ? b : '.';
  16. }
  17. achLine[j] = '\0';
  18. printf( " #%s#\n", achLine );
  19. }
  20. }
  21. TCHAR gszName[MAX_PATH];
  22. LPTSTR MakeCFFmtName( UINT i ) {
  23. switch( i ) {
  24. case CF_TEXT: lstrcpy( gszName, "CF_TEXT"); break;
  25. case CF_BITMAP: lstrcpy( gszName, "CF_BITMAP"); break;
  26. case CF_METAFILEPICT: lstrcpy( gszName, "CF_METAFILEPICT"); break;
  27. case CF_SYLK: lstrcpy( gszName, "CF_SYLK"); break;
  28. case CF_DIF: lstrcpy( gszName, "CF_DIF"); break;
  29. case CF_TIFF: lstrcpy( gszName, "CF_TIFF"); break;
  30. case CF_OEMTEXT: lstrcpy( gszName, "CF_OEMTEXT"); break;
  31. case CF_DIB: lstrcpy( gszName, "CF_DIB"); break;
  32. case CF_PALETTE: lstrcpy( gszName, "CF_PALETTE"); break;
  33. case CF_PENDATA: lstrcpy( gszName, "CF_PENDATA"); break;
  34. case CF_RIFF: lstrcpy( gszName, "CF_RIFF"); break;
  35. case CF_WAVE: lstrcpy( gszName, "CF_WAVE"); break;
  36. case CF_UNICODETEXT: lstrcpy( gszName, "CF_UNICODETEXT"); break;
  37. case CF_ENHMETAFILE: lstrcpy( gszName, "CF_ENHMETAFILE"); break;
  38. case CF_HDROP: lstrcpy( gszName, "CF_HDROP"); break;
  39. case CF_LOCALE: lstrcpy( gszName, "CF_LOCALE"); break;
  40. case CF_MAX: lstrcpy( gszName, "CF_MAX"); break;
  41. case CF_OWNERDISPLAY: lstrcpy( gszName, "CF_OWNERDISPLAY"); break;
  42. case CF_DSPTEXT: lstrcpy( gszName, "CF_DSPTEXT"); break;
  43. case CF_DSPBITMAP: lstrcpy( gszName, "CF_DSPBITMAP"); break;
  44. case CF_DSPMETAFILEPICT:lstrcpy( gszName, "CF_DSPMETAFILEPICT"); break;
  45. case CF_DSPENHMETAFILE: lstrcpy( gszName, "CF_DSPENHMETAFILE"); break;
  46. default:
  47. gszName[0] = TEXT('\0');
  48. GetClipboardFormatName(i, gszName, sizeof(gszName) / sizeof(TCHAR));
  49. break;
  50. }
  51. return gszName;
  52. }
  53. void
  54. __cdecl
  55. main(
  56. int cArgs,
  57. char **szArg
  58. )
  59. {
  60. UINT iCF = 0;
  61. UINT iRet = 0;
  62. LPTSTR szName;
  63. if( cArgs > 1 && (
  64. (*szArg[1] == '-' || *szArg[1] == '/') &&
  65. (szArg[1][1] == '?' || lstrcmpi(&(szArg[1][1]), "help") == 0) ) ) {
  66. fprintf( stderr, "usage: dumpclip [\"clipboard format\"]\n" );
  67. ExitProcess((DWORD)-1);
  68. }
  69. OpenClipboard(NULL);
  70. for( iCF = EnumClipboardFormats( 0 ); iCF != 0; iCF = EnumClipboardFormats( iCF ) ) {
  71. HANDLE hClipData;
  72. PVOID pData;
  73. szName = MakeCFFmtName(iCF);
  74. if (cArgs == 1 || lstrcmpi(szArg[1], szName) == 0 ) {
  75. hClipData = GetClipboardData(iCF);
  76. pData = GlobalLock(hClipData);
  77. printf( "\n%s format:\n", szName );
  78. Dump( pData, (DWORD)GlobalSize(hClipData) );
  79. GlobalUnlock(hClipData);
  80. printf( "\n" );
  81. }
  82. }
  83. CloseClipboard();
  84. ExitProcess(iRet);
  85. }