Jump to content

Recommended Posts

Posted

Func _ChangeDestopWallpaper($bmp, $style = 0)
;===============================================================================
;
; Function Name:    _ChangeDesktopWallPaper
; Description:     Update WallPaper Settings
;Usage:           _ChangeDesktopWallPaper(@WindowsDir & '\' & 'zapotec.bmp',1)
; Parameter(s):  $bmp - Full Path to BitMap File (*.bmp)
;                             [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched
; Requirement(s):   None.
; Return Value(s):  On Success - Returns 0
;                  On Failure -   -1  
; Author(s):        FlyingBoz
;Thanks:        Larry - DllCall Example - Tested and Working under XPHome and W2K Pro
;                    Excalibur - Reawakening my interest in Getting This done.
;
;===============================================================================
      
   If Not FileExists($bmp) Then Return -1
  ;The $SPI*  values could be defined elsewhere via #include - if you conflict,
  ; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic
   Local $SPI_SETDESKWALLPAPER = 20
   Local $SPIF_UPDATEINIFILE = 1
   Local $SPIF_SENDCHANGE = 2
   Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
   if $style = 1 then 
   RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1)
   RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)
Else
   RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
   RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style)
EndIf

   
   DllCall("user32.dll", "int", "SystemParametersInfo", _
         "int", $SPI_SETDESKWALLPAPER, _
         "int", 0, _
         "str", $bmp, _
         "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
   Return 0
EndFunc  ;==>_ChangeDestopWallpaper

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Posted (edited)

@Wouter

No offense, but your example doesn't support styles

Ezz's example doesn't support optional style, and did not work in my w2k environment.

@ALL

If anyone tries this on a different OS and gets unexpected results, please let me know.

Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

  • 3 months later...
Posted

; [$style]- 0 = Centered, 1 = Tiled, 2 = Stretched

The style = 0 in the code basically means that if no style is called, it'll default to 0.
Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...