Changing Windows XP wallpaper

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
 
H

Herfried K. Wagner [MVP]

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
///
 
B

BrammekeDotNet

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?
 
B

BrammekeDotNet

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top