我尝试使用C#更改背景。例如:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern Int32 SystemParametersInfo(UInt32 uiAction, UInt32
uiParam, String pvParam, UInt32 fWinIni);
private static UInt32 SPI_SETDESKWALLPAPER = 20;
private static UInt32 SPIF_UPDATEINIFILE = 0x1;
然后
SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, @"C:\background.bmp", SPIF_UPDATEINIFILE);
}
但它不起作用......帮助?
答案 0 :(得分:1)
pvParam
应该是本地文件。这对网址不起作用......
首先下载图像,然后将其本地路径提供给SystemParametersInfo
方法。
var filename = "4.jpg";
new WebClient().DownloadFile("http://www.scottgames.com/4.jpg", filename);
SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, filename, SPIF_UPDATEINIFILE);