其实就是调用系统api而已,原型是:








1
using System.Runtime.InteropServices;
//////声明下
2
[DllImport("user32.dll", EntryPoint = "SystemParametersInfoA")]
3
static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, string lpvParam, Int32 fuWinIni);//////lpvParam要设置成string
4
private const int SPI_SETDESKWALLPAPER = 20;
5
6
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, filename, 1);/////调用,filename为图片地址,最后一个参数需要为1,0的话在重启后就变回原来的了

//////声明下
2

3

4

5

6

至少vista下成功了。