Sign in to follow this  
Followers 0
ezzetabi

_ChangeWallpaper() Func

7 posts in this topic

#1 ·  Posted (edited)

Func _ChangeWallpaper($sFile,$iType)
  ; Changes the wallpaper to $sFilename using $iType as:
  ; 1 Tiled
  ; 2 Centered
  ; 3 Stretched
  ; any other value (usually 0) unchanged
  ;
  ; Returns
  ; 0 if everything is allright.
  ; -1 if $sFile does not exist. @error is set to 1
  ; -2 if £sFile is not a .bmp file. @error is set to 2
   
   If Not FileExists($sFile) Then
      SetError(1)
      Return -1
   EndIf
   If StringTrimLeft($sFile,StringInStr($sFile,'.',0,-1)) <> 'bmp' Then
      SetError(2)
      Return -2
   EndIf
   
   Select
   Case $iType = 1
      RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','1')
      RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0')
   Case $iType = 2
      RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0')
      RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0')
   Case $iType = 3
      RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0')
      RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','2')
   Case Else
    ;
   EndSelect
   
   RegWrite('HKCU\Control Panel\Desktop','Wallpaper','reg_sz',$sFile)
   DllCall("user32","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0)
   
   Return 0
EndFunc

:)

Edited by ezzetabi

Share this post


Link to post
Share on other sites



That's nice.

I'll test it later.

A question: Does it have to be a bmp file?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes. non .bmp can be set only via Active desktop and it can't be done via this dllcall.

Maybe I'll try to implement (again via dllcall) an autoconversion to .bmp later.

So it woud become avaiable also .jpg, .jpeg and non animated .gif

Edit: sorry, I can't find any info about mwgfx.dll for converting. So only .bmp :) .

Edited by ezzetabi

Share this post


Link to post
Share on other sites

I run it, but nothings happend?

Share this post


Link to post
Share on other sites

mmm.. I can't say. I disabled Active desktop completly.

Share this post


Link to post
Share on other sites

DllCall("user32","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0)

isn't that supposed to be a varible? or something infront of it. if i copy it just as is on windows 2000 it just errors out? :)


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

$sFile is a variable.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0