News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Changing windows desktop wallpaper on the fly.

Started by white scorpion, July 03, 2005, 10:18:02 PM

Previous topic - Next topic

white scorpion

Hi all,

I'm planning on writing a program which will change the wallpaper on the desktop after a given time to another image. This will be kinda like a slideshow. I know there are already many programs which allow you to do such a thing, but i like to write it for myself to keep it simple.

My problem is that i cannot find any way to change the wallpaper on todays windows systems. I have found the API SetDeskWallpaper() exported by user32.dll, but it seems it is still there for compatibility with older programs since it isn't explained in the msdn or API reference anymore.
Apparently it was used even before windows 95 so that's a long time ago.

I've tried using an API monitor to figure out which API's are called when one changes his desktop wallpaper, but it doesn't really make sense.

Anyone knows how to achieve such a thing?

Thanks in advance,

Mark Vogels


arafel

maybe the following will work. (never tested it..)

invoke SystemParametersInfo, SPI_SETDESKWALLPAPER, 0, ADDR path_to_the_wallpaper, 0

GregL

Here's an example I wrote:


; Change Desktop Wallpaper
.486
.MODEL FLAT, stdcall
option casemap:none

INCLUDE windows.inc

INCLUDE kernel32.inc
INCLUDE user32.inc
INCLUDE masm32.inc

INCLUDELIB kernel32.lib
INCLUDELIB user32.lib
INCLUDELIB masm32.lib

.DATA

    lResult     SDWORD  0
    szFileName  BYTE    "D:\My Documents\My Pictures\Wallpaper\Olympic.bmp", 0   ; must be a bitmap
    szTitle     BYTE    "Set Desktop Wallpaper", 0
    szMsgOK     BYTE    "The Desktop Wallpaper was successfully set", 0
    szMsgError  BYTE    "The Desktop Wallpaper was NOT successfully set", 0

.CODE

start:

    invoke SystemParametersInfo, SPI_SETDESKWALLPAPER, NULL, ADDR szFileName, \
           SPIF_UPDATEINIFILE OR SPIF_SENDWININICHANGE OR SPIF_SENDCHANGE
    mov lResult, eax

    .IF eax != 0

        invoke MessageBox, NULL, ADDR szMsgOK, ADDR szTitle, MB_OK

    .ELSE

        invoke MessageBox, NULL, ADDR szMsgError, ADDR szTitle, MB_ICONERROR

    .ENDIF

    invoke ExitProcess, 0

end start           


white scorpion

Thanks guys,

i will go and check out the code. I can't imagine there isn't a possibility to use a jpg as wallpaper, so i will google using the functions / parameters given. At least now i know what to search for  :U

GregL

white scorpion,

Windows XP will accept .jpg files to use as wallpaper, but it first converts them to .bmp and stores the .bmp on disk, then it uses the .bmp for the wallpaper. It stores the .bmp file here:

  C:\Documents and Settings\%USERNAME%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp

The registry keys containing this information are here:

  HKEY_CURRENT_USER\Control Panel\Desktop
   
  ConvertedWallpaper
  OriginalWallpaper
  Wallpaper

I can't remember if Windows 2000 does this or not.






white scorpion

I've noticed that after googeling for the SystemParametersInfo in combination with jpg. Is there any easy way to convert a jpg/png to a bmp file using the API's ?