ho chiesto a ChatGPT

codice:
Imports System.Runtime.InteropServices


Public Class WallpaperChanger
    <DllImport("user32.dll", CharSet:=CharSet.Auto)>
    Private Shared Function SystemParametersInfo(ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
    End Function


    Private Const SPI_SETDESKWALLPAPER As Integer = 20
    Private Const SPIF_UPDATEINIFILE As Integer = &H1
    Private Const SPIF_SENDCHANGE As Integer = &H2


    Public Shared Sub SetWallpaper(ByVal monitorIndex As Integer, ByVal imagePath As String)
        SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, imagePath, SPIF_UPDATEINIFILE Or SPIF_SENDCHANGE Or If(monitorIndex = 1, &H2, 0))
    End Sub


    Public Shared Sub Main()
        ' Path to the image for the first monitor
        Dim firstMonitorImagePath As String = "C:\Path\To\First\Monitor\Wallpaper.jpg"


        ' Path to the image for the second monitor
        Dim secondMonitorImagePath As String = "C:\Path\To\Second\Monitor\Wallpaper.jpg"


        ' Set the wallpaper for the first monitor
        SetWallpaper(0, firstMonitorImagePath)


        ' Set the wallpaper for the second monitor
        SetWallpaper(1, secondMonitorImagePath)
    End Sub
End Class