Advertisement
2_2002-2004 Windows API Call/ Explanation #119383

Correctly setting Desktop Wallpaper

I got tired of trying every wallpaper example on this site and finding they didn't work on Windows NT. This shows the example from Microsoft of how to correctly set the Desktop Wallpaper from Visual Basic. Original code is from :- http://msdn.microsoft.com/library/techart/msdn_msdn192.htm Seeing we are not allowed to link to another site, I just copied the code from the above URL and modified it slightly.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private Sub Command1_Click()
  Dim X As Long
  X = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, "(None)", _
	SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
  MsgBox "Wallpaper was removed"
End Sub
Private Sub Command2_Click()
  Dim FileName As String
  Dim X As Long
  ' Windows NT
  FileName = "c:\winnt\Coffee Bean.bmp"
  ' Windows 95 users, uncomment this line, you can delete the previous line
'  FileName = "c:\windows\Coffee Bean.bmp"

  X = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, FileName, _ 
	SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
  MsgBox "Wallpaper was changed"
End Sub
Original Comments (3)
Recovered from Wayback Machine