设置墙纸(可用htm,bmp)

来源:互联网 发布:js怎么给元素改变属性 编辑:程序博客网 时间:2024/04/20 22:50

procedure setwallpic(picpath :string);
var
hr:hresult;
wall:iactivedesktop;
aa:pwidechar;
begin

 activex.CoInitialize(nil);
 hr:=CoCreateInstance(CLSID_ActiveDesktop, nil, CLSCTX_INPROC_SERVER,
                      stringtoguid(SID_IActiveDesktop),wall);

  if hr=s_ok then
  begin
  getmem(aa,255);
  stringtowidechar('',aa,255);
try
  wall.SetWallpaper(aa,0);
  stringtowidechar(picpath,aa,255);
  wall.SetWallpaper(aa,0);
  wall.ApplyChanges(AD_APPLY_ALL);
  freemem(aa,255);
except
on e:exception do
begin
wall.._Release;
showmessage(e.message);
end; 
end;
end;
 activex.CoUninitialize;
end;
end;

end;

原创粉丝点击