I'd like to write a program that would run at startup, and would randomly choose a desktop background from a folder of images, and make Windows use that image. Any ideas how to change the background in code?
Change the desktop background in code
Miscellaneous Forums/General Discussion/Change the desktop background in code the wallpaper appears to be stored in the registry here: HKEY_USERS\S-1-5-21-682003330-1417001333-839522115-1004\Control Panel\Desktop
on my machine.
*EDIT*
although it looks like SetSystemParametersInfo() combined with SPI_SETDESKWALLPAPER might be a safer bet
although if you're going for a registry approach, HKEY_CURRENT_USER\Control Panel\Desktop\wallpaper looks better than my first registry entry
on my machine.
*EDIT*
although it looks like SetSystemParametersInfo() combined with SPI_SETDESKWALLPAPER might be a safer bet
although if you're going for a registry approach, HKEY_CURRENT_USER\Control Panel\Desktop\wallpaper looks better than my first registry entry
This C#/VB example should be simple enough to convert.
http://blogs.msdn.com/coding4fun/archive/2006/10/31/912569.aspx
http://blogs.msdn.com/coding4fun/archive/2006/10/31/912569.aspx
Here's a little app that will change the background regularly:
Framework brl.linkedlist Import brl.filesystem Import brl.retro Import leadwerks.appsettings Const SPI_SETDESKWALLPAPER=20 Extern "win32" Function SystemParametersInfoA:Int(uiAction,uiParam,pvParam$z,fWinIni) EndExtern bgpath$=AppDir LoadAppSettings() bgpath=AppSetting("wallpaperdir",bgpath) Local list:TList=New TList d=ReadDir(bgpath) If Not d End Repeat file$=NextFile(d) If file="" Exit If Lower(ExtractExt(file))="bmp" count:+1 list.addlast bgpath+"/"+file EndIf Forever CloseDir d SeedRnd MilliSecs() Repeat Delay 1000*60*5 bgfile$=String(list.valueatindex(Rand(0,count-1))) SystemParametersInfoA SPI_SETDESKWALLPAPER,0,bgfile,0 Forever End
is leadwerks.appsettings available somewhere ? I'd a quick look at your website but it wasn't obvious...