locked
SetWallPaper Function RRS feed

  • Question

  • When I run Flickr it always leaves the last picture showing on the desktop.  I was wanting to set it back to what it was before running Flickr.  In the Control Panel for the Desktop Background I just have None selected which gives (for me) a blank blue screen.  I know that if I select one of the .bmp files I can set the desktop to that file and that works just fine.  So, I thought I would be able to set it to None by using an empty string.

    Desktop.SetWallPaper=""

    That appears to work in that I don't get an error when I run the program, but it doesn't change the WallPaper back to None.  So, it seems the function won't allow setting  Wallpaper to a blank screen in the registry.  Is there any way to do this?
    Tuesday, March 3, 2009 1:21 PM

Answers

  • This code is in C#, please convert it to VB.

    private const int SPI_SETDESKWALLPAPER = 20; 
    private const int SPIF_UPDATEINIFILE = 0x1; 
    private const int SPIF_SENDWININICHANGE = 0x2; 
     
    [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)] 
    public static extern int SystemParametersInfo(int uAction , int uParam , string lpvParam , int fuWinIni); 
     
    SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "(None)", SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); 


    Thanks, A.m.a.L
    • Proposed as answer by Kenky Dude Friday, March 6, 2009 6:00 AM
    • Marked as answer by Xingwei Hu Monday, March 9, 2009 12:15 AM
    Tuesday, March 3, 2009 1:29 PM
  • Hi jricestk,

    This is VB code that convert from Amal's post:
    Imports System.ComponentModel  
    Imports System.Windows.Forms  
    Imports System.Data  
    Imports System.Runtime.InteropServices  
    Imports System.IO  
     
    Public Class Form1  
     
        <DllImport("user32.dll", CharSet:=CharSet.Auto)> _  
        Public Shared Function SystemParametersInfo(ByVal uAction As IntegerByVal uParam As IntegerByVal lpvParam As StringByVal fuWinIni As IntegerAs Integer 
        End Function 
     
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
            SystemParametersInfo(20, 0, "(None)", &H1 Or &H2)  
        End Sub 
    End Class 

    Does this works for you? If you have any questions or concerns, please update the thread and we will have a further discussion.

     

     

    Best Regards

    Yichun Feng


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Xingwei Hu Monday, March 9, 2009 12:15 AM
    Thursday, March 5, 2009 6:10 AM

All replies

  • This code is in C#, please convert it to VB.

    private const int SPI_SETDESKWALLPAPER = 20; 
    private const int SPIF_UPDATEINIFILE = 0x1; 
    private const int SPIF_SENDWININICHANGE = 0x2; 
     
    [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)] 
    public static extern int SystemParametersInfo(int uAction , int uParam , string lpvParam , int fuWinIni); 
     
    SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "(None)", SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); 


    Thanks, A.m.a.L
    • Proposed as answer by Kenky Dude Friday, March 6, 2009 6:00 AM
    • Marked as answer by Xingwei Hu Monday, March 9, 2009 12:15 AM
    Tuesday, March 3, 2009 1:29 PM
  • Hi jricestk,

    This is VB code that convert from Amal's post:
    Imports System.ComponentModel  
    Imports System.Windows.Forms  
    Imports System.Data  
    Imports System.Runtime.InteropServices  
    Imports System.IO  
     
    Public Class Form1  
     
        <DllImport("user32.dll", CharSet:=CharSet.Auto)> _  
        Public Shared Function SystemParametersInfo(ByVal uAction As IntegerByVal uParam As IntegerByVal lpvParam As StringByVal fuWinIni As IntegerAs Integer 
        End Function 
     
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
            SystemParametersInfo(20, 0, "(None)", &H1 Or &H2)  
        End Sub 
    End Class 

    Does this works for you? If you have any questions or concerns, please update the thread and we will have a further discussion.

     

     

    Best Regards

    Yichun Feng


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Xingwei Hu Monday, March 9, 2009 12:15 AM
    Thursday, March 5, 2009 6:10 AM