Devi usare sempre la API SystemParametersInfo, ma con SPI_GETDESKWALLPAPER; il fatto però di dover recuperare una stringa da una API costringe ad usare una signature leggermente diversa:
codice:
<DllImport("user32.dll", CharSet:=CharSet.Unicode, EntryPoint:="SystemParametersInfoW")> _
Private Shared Function SystemParametersInfoGetStr(ByVal uAction As Integer, _
ByVal uParam As Integer, ByVal lpvParam As System.Text.StringBuilder, <MarshalAs(UnmanagedType.Bool) > ByVal fuWinIni As Bool) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
Private Const SPI_GETDESKWALLPAPER = &H73
'Nella tua Sub
Dim WallpaperPath As New StringBuilder(260)
If SystemParametersInfoGetStr(SPI_GETDESKWALLPAPER, 0, WallpaperPath, False) Then
' ora in WallpaperPath hai il percorso del wallpaper
Else
' si è verificato un errore, gestiscilo in qualche maniera
End If