Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refresh desktop after changeing the wallpaper

Status
Not open for further replies.

sa5cha

Programmer
May 29, 2001
34
DE
Hi Everyone,

I would need some help on how to refresh the Desktop after deleting the wallpaper in the registry. Does someone knows how to make that with a vbs command? I searched the Forum without a success.

Thx in advance
Sascha


'Delete Current Wallpaper
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper", "", "REG_SZ"


 
Solving that problem with a simple vbs script wont work that easy. I found a solution with vb thats ok for me.

I will post it here too, even if its not a vbs solution. Everyone that searches for a solution in that case too here is an alternative:

- It works with VB6
- Use BMPs as wallpaper to test it, jpegs somehow wont work
- Command1 will clear the wallpaper
- Command2 will set a wallpaper located at C:\TEMP\logo.bmp



Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As String, ByVal fuWinIni As Long) As Long

'Code to Changeing the Wallpaper
Sub ChangeWallpaper(BMPfilename As String, UpdateRegistry As Boolean)
If UpdateRegistry Then
SystemParametersInfo 20, 0, BMPfilename, 1
Else
SystemParametersInfo 20, 0, BMPfilename, 0
End If
End Sub


'Button Command1 will clear the wallpaper
Private Sub Command1_Click()
'No Wallpaper
ChangeWallpaper "", True
End Sub

'Button Command2 will set the wallpaper
Private Sub Command2_Click()
'C:\TEMP\logo.bmp as wallpaper
ChangeWallpaper "C:\TEMP\logo.bmp", True
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top