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;