4

How can I get the name of the current desktop wallpaper in Windows, using C#?

Mark
  • 2,372
  • 11
  • 28
  • 48
Luis
  • 2,608
  • 7
  • 42
  • 70

2 Answers2

5

Something like this?

var wpReg = Registry.CurrentUser.OpenSubKey( "Control Panel\\Desktop", false );
var wallpaperPath = wpReg.GetValue( "WallPaper" ).ToString();
wpReg.Close();

From the path you can extract the filename ...

tanascius
  • 51,705
  • 21
  • 111
  • 133
2

Based on @tanascius's answer, I came up with this code.

Windows 7:

var wpReg = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Desktop\\General\\", false);
var wallpaperPath = wpReg.GetValue("WallpaperSource").ToString();
wpReg.Close();

Windows XP:

var wpReg = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", false);
var wallpaperPath = wpReg.GetValue("WallPaper").ToString();
wpReg.Close();
osvein
  • 595
  • 2
  • 9
  • 30
Luis
  • 2,608
  • 7
  • 42
  • 70