Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VB .Net -- Changing the desktop background image

Posted on 2003-02-19
4
Medium Priority
?
1,339 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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

564 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