本文整理自网络,侵删。
var
reg:TRegistry;
begin
reg:=TRegistry.Create;
reg.RootKey:=HKEY_CURRENT_USER;
reg.OpenKey('Control Panel\Desktop\',False); //打开键值
reg.WriteString('Wallpaper',Edit1.Text); //覆盖写入新的壁纸路径 注:壁纸文件只能是BMP格式,其它格式需要转换才行
reg.WriteString('WallpaperStyle','2'); //写入壁纸在屏幕的显示方式,0:平铺,1:居中,2:拉伸
reg.CloseKey;
reg.Free;
Systemparametersinfo(SPI_SETDESKWallpaper,0,Nil,SPIF_SendChange); //向Windows发送消息,通知Windows更换壁纸
//WinExec('cmd /c gpupdate /force /wait:0',SW_HIDE); //结果跟上一句代码相似,速度感觉慢一点儿
相关阅读 >>
Delphi fdconnection查看所有表包含用户表和系统表
Delphi 判断两个时间差是否在一个指定范围内 -withinpastyears、withinpastmonths、withinpastweeks、withinpastdays
更多相关阅读请进入《Delphi》频道 >>