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 :-)
hm, this looks like a promising place to start:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=304&lngWId=3
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?
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.
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
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! :)
The original request did not specify host language for the API call.
You owe me +1.
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
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.
Even though it is VB...maybe it will help some.
http://msdn.microsoft.com/archive/en-us/dnarvbtips/html/msdn_msdn192.asp
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.
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..
:-\ :-\
Just copy and paste it won't let u use full link.
>:( >:( >:(
Are you incapable of using the proper forum tags? It's incredibly easy to use the "full link." (http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=Season+Changing+Desktop+for+FREE&btnG=Google+Search)
To lazzy it takes to much brain power.
Or.... I just didn't think of that.