Changing Windows XP wallpaper

  • Thread starter Thread starter BrammekeDotNet
  • Start date Start date
B

BrammekeDotNet

Hi,

I'm trying to programatically (VB .NET 2003) change the wallpaper on my
Windows XP machine. I can see the desktop refreshing, but the wallpaper
itself never changes. I also can't make it blank by sending a
null-string (not illustrated here).

This is the code I wrote:


---
Declare Function SystemParametersInfo Lib "user32.dll" Alias
"SystemParametersInfoA" (ByVal uiAction As Long, ByVal uiParam As Long,
ByVal pvParam As Object, ByVal fWinIni As Long) As Boolean

---

Const SPI_SETDESKWALLPAPER = &H14
Const SPI_SETDESKPATTERN = &H15

Const SPIF_UPDATEINIFILE = &H1
Const SPIF_SENDWININICHANGE = &H2
Const SPIF_SENDCHANGE = SPIF_SENDWININICHANGE

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, filename,
SPIF_UPDATEINIFILE Or SPIF_SENDCHANGE)
---


Could someone give me a clue here? :/

Thanks!
Bram
 
BrammekeDotNet said:
Declare Function SystemParametersInfo Lib "user32.dll" Alias
"SystemParametersInfoA" (ByVal uiAction As Long, ByVal uiParam As Long,
ByVal pvParam As Object, ByVal fWinIni As Long) As Boolean

\\\
Public Declare Function SystemParametersInfo _
Lib "user32.dll" _
Aloas "SystemParametersInfoA" _
( _
ByVal uiAction As UInt32, _
ByVal uiParam As UInt32, _
ByVal pvParam As IntPtr, _
ByCal fWinIni As UInt32 _
) As Boolean
///
 
Looks very much like my code, except for the type declarations.

Error message on pvParam: "Value of type 'String' cannot be converted
to 'System.IntPtr'." How do I send a pointer which points to my string?
 
For the collective archive we call "the Internet", this fixed the
problem:

Declare Function SystemParametersInfo Lib "user32.dll" Alias
"SystemParametersInfoA" (ByVal uiAction As Integer, ByVal uiParam As
Integer, ByVal pvParam As String, ByVal fWinIni As Integer) As Integer
Mind the type of pvParam...
 
Back
Top