Page 1 of 1

Get the current Desktop Wallpaper

Posted: Sun Jun 02, 2013 9:10 pm
by XTechVB
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:
Code: Select all
using Microsoft.Win32;
Now inside your class put this code:
Code: Select all
        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;
            }
        }
Calling that method is as simple as this for example:
Code: Select all
this.BackgroundImage = GetCurrentWallpaper();
That's it! I know its not much but i believed it was worth sharing. :D

Re: Get the current Desktop Wallpaper

Posted: Sun Jun 02, 2013 9:42 pm
by Dummy1912
nice share :)

Re: Get the current Desktop Wallpaper

Posted: Mon Jun 03, 2013 12:05 pm
by noypikami
thank you for sharing.... +rep :)