home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP6.ZIP / DUMPICON.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  4.3 KB  |  131 lines

  1. /*
  2.     DUMPICON.C -- Uses DumpIcon to dump WINIO class icon and cursor
  3.  
  4.     From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
  5.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  6.  
  7.     Build using: WINIOBC DUMPICON (for Borland C++ v3.00)
  8.                  WINIOMS DUMPICON (for Microsoft C/SDK)
  9. */
  10.  
  11. #include <windows.h> 
  12. #include "winio.h" 
  13.  
  14. /* undocumented structure */ 
  15. #include "cursicon.h"
  16.  
  17. /* undocumented function */ 
  18. extern DWORD FAR PASCAL DumpIcon(LPCURSORICONINFO lpInfo,
  19.                 WORD FAR *lpLen,        // Length of header 
  20.                 LPSTR FAR *lpXORBits,   // Pointer to XOR bits 
  21.                 LPSTR FAR *lpANDMask    // Pointer to AND bits 
  22.                 ); 
  23.  
  24. #include "checkord.c" 
  25.  
  26. int main()  
  27.     {
  28.     LPCURSORICONINFO lpInfo;
  29.     DWORD dwSize; 
  30.     WORD wHdrLen; 
  31.     LPSTR lpXOR; 
  32.     LPSTR lpAND; 
  33.      
  34.     // Ord/name check 
  35.     if (! CheckOrdName("DumpIcon", "USER", 459))
  36.         return 0; 
  37.  
  38.     winio_about("DUMPICON"
  39.         "\nUses DumpIcon to dump WINIO class icon and cursor"
  40.         "\n\nFrom Chapter 6 of"
  41.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  42.         "\nby Andrew Schulman, David Maxey and Matt Pietrek"
  43.         );
  44.     
  45.     lpInfo = (LPCURSORICONINFO) LockResource( 
  46.                 (HANDLE) GetClassWord(winio_current(), GCW_HCURSOR)); 
  47.     if ((dwSize = DumpIcon(
  48.             lpInfo,
  49.             (WORD FAR *) &wHdrLen, 
  50.             (LPSTR FAR *) &lpXOR, 
  51.             (LPSTR FAR *) &lpAND)) == 0) 
  52.         { 
  53.         printf("Could not DumpIcon the class cursor...!\n"); 
  54.         return 0; 
  55.         } 
  56.      
  57.     FreeResource((HANDLE) GetClassWord(winio_current(), GCW_HCURSOR)); 
  58.  
  59.     winio_setpaint(__hMainWnd, FALSE);
  60.     printf( "Dump of the winio_app class CURSOR\n" 
  61.             "----------------------------------\n" 
  62.             "Header length        : %d bytes\n"
  63.             " Hotspot X           : %d\n"
  64.             " Hotspot Y           : %d\n"
  65.             " Width               : %d\n"
  66.             " Height              : %d\n"
  67.             " Width in bytes      : %d\n"
  68.             " Bit planes          : %d\n"
  69.             " Bits per Pixel      : %d\n"
  70.             "Single plane size    : %d\n" 
  71.             "Full bitmap size     : %d\n" 
  72.             "XOR bitmap address   : %Fp\n" 
  73.             "AND bitmap address   : %Fp\n\n", 
  74.                 wHdrLen,
  75.                 lpInfo->pntHotSpot.x,
  76.                 lpInfo->pntHotSpot.x,
  77.                 lpInfo->nWidth,
  78.                 lpInfo->nHeight,
  79.                 lpInfo->nWidthBytes,
  80.                 lpInfo->byPlanes,
  81.                 lpInfo->byBitsPix,
  82.                 (WORD) dwSize, 
  83.                 (WORD) (dwSize >> 16), lpXOR, lpAND); 
  84.      
  85.     lpInfo = (LPCURSORICONINFO) LockResource( 
  86.                 (HANDLE) GetClassWord(winio_current(), GCW_HICON)); 
  87.     if ((dwSize = DumpIcon(
  88.             lpInfo,
  89.             (WORD FAR *) &wHdrLen,
  90.             (LPSTR FAR *) &lpXOR, 
  91.             (LPSTR FAR *) &lpAND)) == 0) 
  92.         { 
  93.         printf("Could not DumpIcon the class icon...!\n"); 
  94.         return 0; 
  95.         }
  96.      
  97.     FreeResource((HANDLE) GetClassWord(winio_current(), GCW_HICON)); 
  98.      
  99.     printf( "Dump of the winio_app class ICON\n" 
  100.             "--------------------------------\n" 
  101.             "Header length        : %d bytes\n" 
  102.             " Hotspot X           : %d\n"
  103.             " Hotspot Y           : %d\n"
  104.             " Width               : %d\n"
  105.             " Height              : %d\n"
  106.             " Width in bytes      : %d\n"
  107.             " Bit planes          : %d\n"
  108.             " Bits per Pixel      : %d\n"
  109.             "Single plane size    : %d\n" 
  110.             "Full bitmap size     : %d\n" 
  111.             "XOR bitmap address   : %Fp\n" 
  112.             "AND bitmap address   : %Fp\n\n", 
  113.                 wHdrLen,
  114.                 lpInfo->pntHotSpot.x,
  115.                 lpInfo->pntHotSpot.x,
  116.                 lpInfo->nWidth,
  117.                 lpInfo->nHeight,
  118.                 lpInfo->nWidthBytes,
  119.                 lpInfo->byPlanes,
  120.                 lpInfo->byBitsPix,
  121.                 (WORD) dwSize, 
  122.                 (WORD) (dwSize >> 16), lpXOR, lpAND); 
  123.  
  124.     
  125.     printf("Program terminated"); 
  126.     winio_setpaint(__hMainWnd, TRUE);
  127.     winio_home(__hMainWnd);
  128.     return 0; 
  129.     } 
  130.  
  131.