Inserire in un modulo il seguente codice VB.NET:
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
Inserire il seguente codice VB.NET in un evento:
Const ImagePath As String = "C:\Ciao.bmp" ' Path del file immagine Const ImageStyle As Integer = 0 ' Stile della visualizzazione dell'immagine Try Dim Key As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Control Panel\Desktop", True) Dim WallpaperStyle As Object = Nothing ' Stile della immagine Dim TileWallpaper As Object = Nothing ' Stile della immagine affiancata Select Case ImageStyle Case 0 ' Al centro WallpaperStyle = "1" TileWallpaper = "0" Case 1 ' Affiancata WallpaperStyle = "1" TileWallpaper = "1" Case 2 ' Estesa WallpaperStyle = "2" TileWallpaper = "0" End Select Key.SetValue("WallpaperStyle", WallpaperStyle) Key.SetValue("TileWallpaper", TileWallpaper) Key.Close() SystemParametersInfo(20, 0, ImagePath, &H1) ' Imposta lo sfondo del desktop Catch ex As Exception MessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try
Ovviamente le costanti ImagePath e ImageStyle devono essere modificate. Ciao.
Aggiungi un commento