Get the current Desktop Wallpaper

All tutorials created in C# to be posted in here.
3 posts Page 1 of 1
Contributors
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Get the current Desktop Wallpaper
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
You can find me on Facebook or on Skype mihai_92b
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

nice share :)
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

thank you for sharing.... +rep :)
3 posts Page 1 of 1
Return to “C-Sharp Tutorials”