Change Wallpaper

drschlong

Registered User.
Local time
Today, 23:39
Joined
Jun 12, 2002
Messages
33
Hi all, I am trying to change the wallpaper on the desktop through Access, I have the attached code which half works but I'm going to need somebodys help to get it working correctly.

Option Compare Database
Option Explicit

Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPI_SETDESKWALLPAPER = 20
Private Const SPIF_SENDWININICHANGE = &H2

' Enter the following Declare as one, single line:

Private Declare Function SystemParametersInfo Lib "User32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uparam As Integer, lpvParam As Any, ByVal fuWinIni As Integer) As Integer


Private Sub Command1_Click()
Dim filenm As String
Dim x As Long

filenm = "c:\winnt\Bgt.bmp"

' Enter the following two lines as one, single line:
x = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, filenm, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub

The code is attached to a button on a form, when I click the button it clears the current wallpaper on the desktop but doesn't replace it with the file I specified. Can anybody see where I am going wrong and help me out.

Thanks in advance. Steven.
 
A little bit of effort in searching the net will go a long ways. Especially when you are asking a Windows operating system question in an Access forum.

Code:
Option Compare Database
Option Explicit
 
'http://searchvb.techtarget.com/ateQuestionNResponse/0,289625,sid8_gci905773,00.html
 
Private Const SPI_SETDESKWALLPAPER = 20
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1
 
Private 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 Sub SetWallpaper(ByVal FileName As String)
   
  Dim ret As Long
  ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, FileName, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
 
End Sub
 
Public Sub TESTING()
[COLOR=Blue]    SetWallpaper ("C:\Windows\Soap Bubbles.bmp")[/COLOR]
End Sub
 

Users who are viewing this thread

Back
Top Bottom