home *** CD-ROM | disk | FTP | other *** search
- /*
- DTPATTRN.C -- Sets the desktop background brush using SetDeskPattern
-
- From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC DTPATTRN (for Borland C++ v3.00)
- WINIOMS DTPATTRN (for Microsoft C/SDK)
- */
-
- #include <windows.h>
- #include "winio.h"
-
- /* undocumented function */
- BOOL (FAR PASCAL *lpfnSetDeskPattern)(void);
-
- int main()
- {
- char buf[128];
-
- winio_about("DTPATTRN"
- "\nSets the desktop background brush using SetDeskPattern"
- "\n\nFrom Chapter 6 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek"
- );
-
- // Get function address
- lpfnSetDeskPattern =
- GetProcAddress(GetModuleHandle("USER"), (LPSTR) (DWORD) 279);
-
- for (;;)
- {
- /* prompt for the pattern */
- puts("Enter 8 bytes of (decimal) pattern data:");
- gets(buf);
-
- /* record the pattern in the win.ini file ... */
- WriteProfileString("Desktop", "Pattern", buf);
-
- /* ... and call the SetDeskPattern function */
- if ((*lpfnSetDeskPattern)())
- {
- InvalidateRect(GetDesktopWindow(), NULL, TRUE);
- printf("Desktop pattern successfully changed\n");
- }
- else
- printf("Could not change desktop pattern\n");
- }
-
- printf("Program terminated");
- return 0;
- }
-