• Welcome to Valhalla Legends Archive.
 

Desktop Wallpaper

Started by iago, October 07, 2003, 12:09 AM

Previous topic - Next topic

iago

Is there an API call or something like that to change the desktop wallpaper in Windows (2k or xp or whatever)?  

I want to make a program that will change wallpaper based on holidays/time of year.  Yes, I'm that bored.

If somebody knows of a program that does that anyway without me having to write it, that's ok too :-)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


iago

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


iago

#2
hmm, it seems to be stored in the registry under:
"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General\Wallpaper"

Now all I have to figure out is how to tell windows to reload the wallpaper :-)

Edit: hmm, I can just close/open explorer.exe, which works.. or I can do this before explorer loads initially.  How early do startup programs run, before or after explorer?

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Eibro

Quote from: iago on October 07, 2003, 12:24 AM
hmm, it seems to be stored in the registry under:
"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General\Wallpaper"

Now all I have to figure out is how to tell windows to reload the wallpaper :-)

Edit: hmm, I can just close/open explorer.exe, which works.. or I can do this before explorer loads initially.  How early do startup programs run, before or after explorer?


You could probably just invalidate the entire desktop and force windows to repaint it.
Eibro of Yeti Lovers.

Grok

   Dim Files() As String, FN As String
   Dim lCnt As Long, bRet As Long
   Static Current As Long
   Dim nAction As Long, nSaveChange As Long
   Dim strPic As String
   
   lCnt = 0
   FN = Dir("C:\Pictures\*.bmp")
   Do While Len(FN) > 0
       lCnt = lCnt + 1
       ReDim Preserve Files(1 To lCnt)
       Files(lCnt) = "C:\Pictures\" & FN
       FN = Dir
   Loop
   Current = Current + 1
   Current = Current Mod lCnt + 1
   nAction = SPI_SETDESKWALLPAPER
   nSaveChange = SPIF_SENDCHANGE
   strPic = Files(Current)
   lblFile = strPic & Chr(0)
   bRet = SystemParametersInfo(nAction, 0, strPic, nSaveChange)
   If bRet = 0 Then
       bRet = GetLastError
       Dim sError As String
       Dim iErr As Long, dwFormatFlags As Long
       iErr = bRet
       dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER + FORMAT_MESSAGE_IGNORE_INSERTS + FORMAT_MESSAGE_FROM_SYSTEM
       bRet = FormatMessage(dwFormatFlags, 0, iErr, 0, sError, 0, 0)
       MsgBox "Error: " & iErr & " - " & sError
   End If

iago

ooh, I get to say this for once!
"eww, visual basic.. can somebody convert it to c++?"
Sorry, I've always wanted to say that :-)


Thanks, Grok!  You're the best! :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Grok

The original request did not specify host language for the API call.

You owe me +1.

iago

Quote from: Grok on October 07, 2003, 01:34 PM
The original request did not specify host language for the API call.

You owe me +1.

haha much like many other posts from people who are looking for help in VB and get in c++ :-P

But I gave you your +1 anyway, making you a nice even 100 :-D
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Eibro

Quote from: Grok on October 07, 2003, 07:21 AM
   Dim Files() As String, FN As String
   Dim lCnt As Long, bRet As Long
   Static Current As Long
   Dim nAction As Long, nSaveChange As Long
   Dim strPic As String
   
   lCnt = 0
   FN = Dir("C:\Pictures\*.bmp")
   Do While Len(FN) > 0
       lCnt = lCnt + 1
       ReDim Preserve Files(1 To lCnt)
       Files(lCnt) = "C:\Pictures\" & FN
       FN = Dir
   Loop
   Current = Current + 1
   Current = Current Mod lCnt + 1
   nAction = SPI_SETDESKWALLPAPER
   nSaveChange = SPIF_SENDCHANGE
   strPic = Files(Current)
   lblFile = strPic & Chr(0)
   bRet = SystemParametersInfo(nAction, 0, strPic, nSaveChange)
   If bRet = 0 Then
       bRet = GetLastError
       Dim sError As String
       Dim iErr As Long, dwFormatFlags As Long
       iErr = bRet
       dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER + FORMAT_MESSAGE_IGNORE_INSERTS + FORMAT_MESSAGE_FROM_SYSTEM
       bRet = FormatMessage(dwFormatFlags, 0, iErr, 0, sError, 0, 0)
       MsgBox "Error: " & iErr & " - " & sError
   End If

If i'm not mistaken you need to call LocalFree on sError after you've displayed the error, else you'll leak memory. I know this needs to be done when calling from C/C++; VB should probably be the same though.
Eibro of Yeti Lovers.


WiLD

Ok dont know if its been answered yet but i got something that works.

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Const SPI_SETDESKWALLPAPER = 20

and the could always make the below show up in a dialog box so u can pick what image.

   SystemParametersInfo SPI_SETDESKWALLPAPER, 0, "C:\BG.GIF", 0


i cant remember where i got this.
=_=  &&  g0dFraY  &&  -=Templar=-  @USWest

-Death-

Why make one dl it.
Use google here is the link:
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=Season+Changing+Desktop+for+FREE&btnG=Google+Search

I already did must say it is pretty cool. If you really wanted to make ure own just decode one and see what there basis for there desktop changer is..

:-\ :-\

-Death-

Just copy and paste it won't let u use full link.

>:(  >:(  >:(

Zakath

Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

-Death-

To lazzy it takes to much brain power.
Or.... I just didn't think of that.