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
In .NET, you can't use the "As Any" on the function declaration. I changed it to "As String" and tried the same code. While it works in VB6, it does not work in .NET. What am I doing wrong?
You need to change the 'As Any' statement to be more specific. Changing it to 'As Long' should work just fine.
This was first published in June 2003