4

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

Mark
  • 2,380
  • 11
  • 29
  • 49
Luis
  • 2,665
  • 8
  • 44
  • 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
  • 53,078
  • 22
  • 114
  • 136
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
  • 625
  • 2
  • 10
  • 31
Luis
  • 2,665
  • 8
  • 44
  • 70