您的位置:首页 > 编程语言 > C#

c#设置桌面壁纸

2008-01-15 22:36 381 查看
其实就是调用系统api而已,原型是:

BOOL WINAPI SystemParametersInfo(
__in UINT uiAction,
__in UINT uiParam,
__in_out PVOID pvParam,
__in UINT fWinIni
);

1using System.Runtime.InteropServices;
//////声明下
2[DllImport("user32.dll", EntryPoint = "SystemParametersInfoA")]
3static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, string lpvParam, Int32 fuWinIni);//////lpvParam要设置成string
4private const int SPI_SETDESKWALLPAPER = 20;
5
6SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, filename, 1);/////调用,filename为图片地址,最后一个参数需要为1,0的话在重启后就变回原来的了
至少vista下成功了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: