利用 Windows 的 API 获取桌面壁纸的实际路径,使用的是 SystemParametersInfo 这个API,此API的功能非常丰富,壁纸操作只是一斑 C#获取桌面壁纸图片的路径(Desktop Wallpaper)

using System.Runtime.InteropServices;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SystemParametersInfo(uint uAction, uint uParam, StringBuilder lpvParam, uint init);

const uint SPI_GETDESKWALLPAPER = 0x0073;
StringBuilder wallPaperPath = new StringBuilder(200);

if (SystemParametersInfo(SPI_GETDESKWALLPAPER, 200, wallPaperPath, 0))
{
    MessageBox.Show(wallPaperPath.ToString());
}

 

搞定!

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
  • 2022-12-23
  • 2022-02-28
猜你喜欢
  • 2022-02-07
  • 2022-01-03
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
相关资源
相似解决方案