Need Code: Upon open, change desktop background
Hey again all, I been trying to look for this and haven't been successful. Can anyone help me with this code? When you open up the application, the background of your desktop will change. I will provide the .jpg or .gif or .jpeg or .tif file. Thanks ahead of time.
Re: Need Code: Upon open, change desktop background
I don't know but I would guess that the location of the current desktop wallpaper is stored in the registry. If that's the case then you need to find the key and value it stored under and then what you want to do is just a matter of opening the key and setting the value.
Re: Need Code: Upon open, change desktop background
Depending on your OS it will be in
(XP)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme\Wallpaper
Re: Need Code: Upon open, change desktop background
Re: Need Code: Upon open, change desktop background
Sorry if I am wrong, but if you want to change the wallpaper, yu can use SystemParametersInfo API at Form's load event.
Code:
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
public static extern void SystemParametersInfoA (int uAction, int uParam, string lpvParam, int fuWinIni);
private const int SPI_SETDESKWALLPAPER = 20;
private const int SPIF_UPDATEINIFILE = 0x0001;
private void Form1_Load(object sender, System.EventArgs e)
{
SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, path of image, SPIF_UPDATEINIFILE);
}