In VB6, I used the following code to change the desktop wallpaper:
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.
Dig Deeper on VB 6 to VB .NET Migration
Related Q&A from John Robbins
What is a JAD session? This term is referred to often in job postings and seems like some kind of brainstorm you carry out with a client to define IT...continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.