Is there any way to set the desktop image in c#????
Here is some code snippet that i found on the net (provided by Heath
Stewart)
I tried this out on my machine and it works, although only for .bmp files.
I tried with a .jpg, it just cleared the current wallpaper on refresh.
.bmp works great.
run this command line application with the path of a bmp file as a
command-line parameter.
using System;
using System.Runtime.InteropServices;
public class Desktop
{
public static int SPI_SETDESKTOPWALLPAPER = 20;
public static int SPIF_UPDATEINIFILE = 1;
public static int SPIF_SENDWININICHANGE = 2;
public static void Main(string[] args)
{
if (args.Length == 1)
SystemParametersInfo(SPI_SETDESKTOPWALLPAPER, 0,
args[0], SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
}
[DllImport("User32.dll")]
private static extern void SystemParametersInfo(int action,
int iparam, string vparam, int option);
}
--
Adrian Mascarenhas, Developer Division
This posting is provided "AS IS" with no warranties, and confers no rights.
Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.