?
Solved

VB .Net -- Changing the desktop background image

Posted on 2003-02-19
4
Medium Priority
?
1,328 Views
Last Modified: 2012-08-13
Tyring to change the desktop image from a VB app.

I'd like to grab an image (.JPG) from the web (specific image) and make that image the windows desktop image.  Ideally the program would run in the background and update the image based on a timer.

I found code for W95 but it doesn't seem to work with 2000/XP.

Thanks!
0
Comment
Question by:Pomarius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
venyon earned 300 total points
ID: 7984689
You will need to use the Win32 APi SystemParametersInfo to do this.

Declare Function SystemParametersInfo _
        Lib "user32.dll" _
        Alias "SystemParametersInfoA" _
       (ByVal uAction As Integer, _
        ByVal uParam As Integer, _
        <MarshalAs(UnmanagedType.LPStr)> ByVal lpvParam As String, _
        ByVal fuWinIni As Integer) As Integer

    Const SPI_SETDESKWALLPAPER As Integer = 20

    Private Sub ChangeWallPaper()

        SystemParametersInfo( _
            SPI_SETDESKWALLPAPER, _
            0, _
            "some.gif", _
            1)

    End Sub

You might need to call RedrawWindow API to see the changes though.
0
 

Author Comment

by:Pomarius
ID: 7985560
Thanks Venyon-

Doesn't appear the compiler likes the "MarshalAs" command...I get a "type undefined" error.

-P
0
 

Author Comment

by:Pomarius
ID: 7987988
UPDATE

Removing the MarshalAs command seemed to correct that problem as I am able to select image files that are in the windows dir as my desktop wallpaper.

So, the question now is how to get the image from the net (I have the URL to the image) into the windows dir so the setdesktop command can change the image file.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9645162
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by venyon

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question