How to get the name of the select wallpaper
How can I get the name of the current d开发者_Go百科esktop wallpaper in Windows, using C#?
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 ...
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();
精彩评论