Here is a simple program that change the desktop wallpaper to an image of your choice. It's very simple because you should write in the code the path of the image of your choice (if you want to give it a try of course). I will try to improve it (maybe) later to have a menu or something like that to choose the path in runtime. :P
title wallpaper.asm For change the desktop wallpaper.
include c:\masm32\include\masm32rt.inc
.data
new_wallpaper byte 'c:\Users\Administrador\Desktop\Programacion\window00\nuevo.bmp',0 ; You can put here whatever path for an image.
.code
start:
main proc
call GetDesktopWindow ; Windows give us a handle for the desktop wallpaper.
push eax ; Not necessary i guess.
call change_wallpaper ; Puts a new wallpaper in the desktop.
call ExitProcess
main endp
change_wallpaper proc ; Puts a new wallpaper.
push SPIF_UPDATEINIFILE ; Updates your user profile.
push offset new_wallpaper ; Pointer to the path of the image.
push 0 ; Must be null (not used).
push SPI_SETDESKWALLPAPER ; To change the desktop wallpaper.
call SystemParametersInfo ; Windows will do just that.
ret
change_wallpaper endp
end start
Hi felipe,
To avoid hardcoded filenames, you can use the command line to specify the wallpaper :
ChgWallPaper.exe wallpaper.bmp
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\msvcrt.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\msvcrt.lib
.data
bWildCard dd 0
.data?
argc dd ?
argv dd ?
pEnv dd ?
StartInfo STARTUPINFO <?>
.code
start:
call main
invoke ExitProcess,0
main PROC
invoke crt___getmainargs,ADDR argc,ADDR argv,\
ADDR pEnv,bWildCard,ADDR StartInfo
cmp argc,2
je @f
ret
@@:
mov eax,argv
invoke SystemParametersInfo,SPI_SETDESKWALLPAPER,\
0,DWORD PTR [eax+4],SPIF_UPDATEINIFILE
ret
main ENDP
END start
Vortex: great job! Works very good.
You are right of course, i was just been studying and practising. :icon14:
Quote_StartInfo
Other information to be passed to the CRT DLL.
that StartInfo can be DWORD with value 0 if nothing passed to CRT DLL ? WindowsXP needs that?
Hi TWell,
The purpose is to conform with the MS specification. A small safety measure.