Get the current Desktop Wallpaper
Posted: Sun Jun 02, 2013 9:10 pm
In this tutorial you will learn how to get the current Desktop Wallpaper using Registry.
Start by creating a Windows Forms Application and import this Namespace:
Start by creating a Windows Forms Application and import this Namespace:
Code: Select all
Now inside your class put this code:
using Microsoft.Win32;
Code: Select all
Calling that method is as simple as this for example:
private Image GetCurrentWallpaper()
{
//Get Registry Key
RegistryKey _RegEntry = Registry.CurrentUser.OpenSubKey("Control Panel" + @"\" + "Desktop", false);
//Check && Return
if (_RegEntry.GetValue("Wallpaper") != null)
{
return Image.FromFile(_RegEntry.GetValue("Wallpaper").ToString());
}
else
{
MessageBox.Show("Registry Value 'Wallpaper' does not exist!");
return null;
}
}
Code: Select all
That's it! I know its not much but i believed it was worth sharing. this.BackgroundImage = GetCurrentWallpaper();