Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Please, if you know how to set the desktop wallpaper by VB.net code so tell me how.

tHIS CODE don't work (I don't know why)::mad:

Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As String, ByVal fuWinIni As Long) As Long

Const SPI_SETDESKWALLPAPER = 20

Const SPIF_UPDATEINIFILE = &H1

 

 

 

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "John5.bmp", SPIF_UPDATEINIFILE)

 

Thank you. :)

  • Leaders
Posted

you really need to use Integers rather than Longs , eg:

   Private 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

   Private Const SPI_SETDESKWALLPAPER As Integer = 20
   Private Const SPIF_UPDATEINIFILE As Integer = 1

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim od As New OpenFileDialog()
       With od
           .Filter = "Bitmaps(*.bmp)|*.bmp" '/// only seems to work on bitmaps ( atleast on XP pro here )
           .InitialDirectory = "C:\"
       End With
       If od.ShowDialog = DialogResult.OK Then
           If MessageBox.Show("would you like the changes to remain next time you re-boot", Application.ProductName, MessageBoxButtons.YesNo) = DialogResult.OK Then
               SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, od.FileName, SPIF_UPDATEINIFILE)
           Else '/// dont save changes for after reboot.
               SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, od.FileName, 0)
           End If
       End If
   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...