【发布时间】:2011-06-18 19:39:59
【问题描述】:
我正在用 VB.NET 编写一个程序,该程序需要获取当前用户壁纸的路径。有谁知道可以做到这一点的方法吗?
【问题讨论】:
-
我真的不希望 - 也读这个devcity.net/Articles/119/1/vb2005_wallpaper.aspx
标签: vb.net
我正在用 VB.NET 编写一个程序,该程序需要获取当前用户壁纸的路径。有谁知道可以做到这一点的方法吗?
【问题讨论】:
标签: vb.net
我知道已经很晚了,但是对于其他人...如果桌面背景(壁纸)是图片(不是纯色),您可以在目录中找到当前图片:
“C:\Users\ {用户名}\AppData\Roaming\Microsoft\Windows\Themes\”
【讨论】:
您可以从注册表中读取当前壁纸。无需任何 API 调用。 这是执行此操作的代码
Private Function GetCurrentWallpaper() As String
' The current wallpaper path is stored in the registry at HKCU\Control Panel\Desktop\WallPaper
Dim rkWallPaper As RegistryKey = Registry.CurrentUser.OpenSubKey("Control Panel\Desktop", False)
Dim WallpaperPath As String = rkWallPaper.GetValue("WallPaper").ToString()
rkWallPaper.Close()
' Return the current wallpaper path
Return WallpaperPath
End Function
【讨论】:
您必须使用 SPI_GETDESKWALLPAPER 调用 SystemParametersInfo()。这将返回壁纸位图文件的路径。访问 pinvoke.net 以获取所需的声明。
【讨论】: