home *** CD-ROM | disk | FTP | other *** search
- /*
- DTWLPAPR.C -- Sets the desktop wallpaper .BMP using SetDeskWallpaper
-
- From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC DTWLPAPR (for Borland C++ v3.00)
- WINIOMS DTWLPAPR (for Microsoft C/SDK)
- */
-
- #include <windows.h>
- #include "winio.h"
-
- /* undocumented function */
- BOOL (FAR PASCAL *lpfnSetDeskWallPaper)(LPSTR lpszBmpFileName);
-
- int main()
- {
- char bmpfilename[64];
-
- winio_about("DTWLPAPR"
- "\nSets the desktop wallpaper .BMP using SetDeskWallpaper"
- "\n\nFrom Chapter 6 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek"
- );
-
- // Get function address
- lpfnSetDeskWallPaper =
- GetProcAddress(GetModuleHandle("USER"), (LPSTR) (DWORD) 285);
-
- for (;;)
- {
- /* prompt for the filename */
- puts("Enter name of .BMP file to use:");
- gets(bmpfilename);
-
- /* break on empty filename */
- if (bmpfilename[0] == 0)
- break;
-
- /* otherwise call the SetDeskWallPaper function */
- if ((*lpfnSetDeskWallPaper)(bmpfilename))
- {
- /* Save name of bitmap in WIN.INI */
- WriteProfileString("Desktop", "Wallpaper", bmpfilename);
- InvalidateRect(GetDesktopWindow(), NULL, TRUE);
- puts("Desktop wallpaper successfully changed.\n");
- }
- else
- puts("Could not change desktop wallpaper...\n");
- }
-
- puts("Program terminated");
- return 0;
- }
-