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

  1. /*
  2.     DTPATTRN.C -- Sets the desktop background brush using SetDeskPattern
  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 DTPATTRN (for Borland C++ v3.00)
  8.                  WINIOMS DTPATTRN (for Microsoft C/SDK)
  9. */
  10.  
  11. #include <windows.h> 
  12. #include "winio.h" 
  13.  
  14. /* undocumented function */ 
  15. BOOL (FAR PASCAL *lpfnSetDeskPattern)(void); 
  16.  
  17. int main() 
  18.     {
  19.     char buf[128]; 
  20.  
  21.     winio_about("DTPATTRN"
  22.         "\nSets the desktop background brush using SetDeskPattern"
  23.         "\n\nFrom Chapter 6 of"
  24.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  25.         "\nby Andrew Schulman, David Maxey and Matt Pietrek"
  26.         );
  27.     
  28.     // Get function address
  29.     lpfnSetDeskPattern =
  30.         GetProcAddress(GetModuleHandle("USER"), (LPSTR) (DWORD) 279);
  31.  
  32.     for (;;)
  33.         {
  34.         /* prompt for the pattern */
  35.         puts("Enter 8 bytes of (decimal) pattern data:");
  36.         gets(buf);
  37.         
  38.         /* record the pattern in the win.ini file ... */
  39.         WriteProfileString("Desktop", "Pattern", buf);
  40.         
  41.         /* ... and call the SetDeskPattern function */
  42.         if ((*lpfnSetDeskPattern)())
  43.             {
  44.             InvalidateRect(GetDesktopWindow(), NULL, TRUE);
  45.             printf("Desktop pattern successfully changed\n");
  46.             }
  47.         else
  48.             printf("Could not change desktop pattern\n");
  49.         }
  50.     
  51.     printf("Program terminated");
  52.     return 0;
  53.     }
  54.