### Author Topic: A program very simple and funny.  (Read 375 times)

#### felipe

• Member
• Posts: 360
• assemble the unassembled.
##### A program very simple and funny.
« on: April 29, 2017, 05:06:37 AM »
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.

Code: [Select]
`            title   wallpaper.asm               For change the desktop wallpaper.                    include c:\masm32\include\masm32rt.inc                    .datanew_wallpaper       byte    'c:\Users\Administrador\Desktop\Programacion\window00\nuevo.bmp',0      ; You can put here whatever path for an image.                     .codestart: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                endpchange_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.                        retchange_wallpaper    endp                    end     start                    `
Felipe.

#### Vortex

• Member
• Posts: 1725
##### Re: A program very simple and funny.
« Reply #1 on: April 29, 2017, 05:58:31 AM »
Hi felipe,

To avoid hardcoded filenames, you can use the command line to specify the wallpaper :

Code: [Select]
`ChgWallPaper.exe wallpaper.bmp`
Code: [Select]
`.386.model flat,stdcalloption casemap:noneinclude     \masm32\include\windows.incinclude     \masm32\include\kernel32.incinclude     \masm32\include\user32.incinclude     \masm32\include\msvcrt.incincludelib  \masm32\lib\kernel32.libincludelib  \masm32\lib\user32.libincludelib  \masm32\lib\msvcrt.lib.databWildCard   dd 0.data?argc        dd ?argv        dd ?pEnv        dd ?StartInfo   STARTUPINFO <?>.codestart:    call    main    invoke  ExitProcess,0main 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    retmain ENDP    END start`

#### felipe

• Member
• Posts: 360
• assemble the unassembled.
##### Re: A program very simple and funny.
« Reply #2 on: April 29, 2017, 07:03:08 AM »
Vortex: great job! Works very good.
You are right of course, i was just been studying and practising.
Felipe.

#### TWell

• Member
• Posts: 748
##### Re: A program very simple and funny.
« Reply #3 on: April 29, 2017, 05:20:30 PM »
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?

#### Vortex

• Member
• Posts: 1725
##### Re: A program very simple and funny.
« Reply #4 on: April 29, 2017, 06:12:06 PM »
Hi TWell,

The purpose is to conform with the MS specification. A small safety measure.