How can I get at the desktop background settings programatically? Are they stored as a registry entry?
How can I get at the desktop background settings programatically? Are they stored as a registry entry?
What sort of background?
If it's just the wallpaper you want to change, and Active Desktop is disabled, then:-
Otherwise I dunno how to change the Active Desktop settings.Code:HKEY hKey; RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_SET_VALUE, &hKey); RegSetValueEx(hKey, "Wallpaper", 0, REG_SZ, "Image.bmp", 10); RegCloseKey(hKey); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);
Never tried this myself, but a search on MSDN turned this up.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
I'll give a brief example but I think this is going to be more informative and include more detail: Set Desktop Color In short:Regards,Code:int aiElements[1] = {COLOR_BACKGROUND}; DWORD aColors[1] = {RGB(0, 255, 0)}; //Green SetSysColors(1, aiElements, aColors);
Brian
Wow, another Brian (bmf is a Brian too amongst others, this should be called brianprogramming.com). Thanks Brian.
Don't forget me!Originally Posted by Brian
Hello,
I need to change the desktop background programming.
The execution of the below .vbs doesn't do anything. What is wrong? Thank you
Code:dim wshShell dim sUserName Set wshShell = WScript.CreateObject("WScript.Shell") sUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%") Set oShell = CreateObject("WScript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") sWinDir = oFSO.GetSpecialFolder(0) sWallPaper = "C:\Documents and Settings\Simpatico\My Documents\Woerter Speichern Files\lastvocab.png" ' update in registry oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper ' let the system know about the change oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
any help on this?
If you only want to change the wallpaper then there is absolutely no need to go through the registry for it.
Just specify a filename instead of NULL as third parameter. Windows versions prior to Vista will only accept .BMP files, so you'll have to convert them first unless you programm only needs to run on vista/7.Code:SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, filename, SPIF_UPDATEINIFILE);
I need a complete script example.
I've found this on microsoft's website, but nothing happens when I execute the script and log out.
(I've placed the file also in the system32 folder, let alone changing the path.
Code:Const HKEY_CURRENT_USER = &H80000001 strComputer = "." Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") intLowNumber = 1 intHighNumber = 6 Randomize intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber) Select Case intNumber Case 1 strValue = "C:\WINDOWS\System32\Wallpaper1.bmp" Case 2 strValue = "C:\WINDOWS\System32\Wallpaper2.bmp" Case 3 strValue = "C:\WINDOWS\System32\Wallpaper3.bmp" Case 4 strValue = "C:\WINDOWS\System32\Wallpaper4.bmp" Case 5 strValue = "C:\WINDOWS\System32\Wallpaper5.bmp" Case 6 strValue = "C:\WINDOWS\System32\Wallpaper6.bmp" End Select strKeyPath = "Control Panel\Desktop" ValueName = "Wallpaper" objReg.SetStringValue HKEY_USERS, strKeyPath, ValueName, strValue