其实就是调用系统api而已,原型是:
BOOL WINAPI SystemParametersInfo(
__in UINT uiAction,
__in UINT uiParam,
__in_out PVOID pvParam,
__in UINT fWinIni
);

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的话在重启后就变回原来的了
using System.Runtime.InteropServices;//////声明下
2
[DllImport("user32.dll", EntryPoint = "SystemParametersInfoA")]3
static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, string lpvParam, Int32 fuWinIni);//////lpvParam要设置成string4
private const int SPI_SETDESKWALLPAPER = 20;5

6
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, filename, 1);/////调用,filename为图片地址,最后一个参数需要为1,0的话在重启后就变回原来的了至少vista下成功了。
浙公网安备 33010602011771号