如何获取选择壁纸的名称

如何使用C#在Windows中获取当前桌面墙纸的名称?

像这样的东西?

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

从路径中,您可以提取文件名…

基于@tanascius的回答,我想出了这段代码。

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();