Bueno. Aqui una sencilla modificacion del truco anterior, pero no para cambiar el color de fondo. Sino la imagen de fondo pero con ADSI. Esto cambia el fondo del escritorio aunque este restringida esta opcion por el admin de red jejejeje.
Código Delphi
[-]uses ShlObj, ActiveX, ComObj, Registry;
procedure SetDesktopBackgroundImage(vBmpPath: String);
var
shDesk: IActiveDesktop;
vWallPOp: TWallPaperOpt;
begin
try
shDesk := (CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop);
shDesk.SetWallpaper(StringToOleStr(vBmpPath), 0);
vWallPOp.dwSize := Sizeof(TWallPaperOpt);
vWallPOp.dwStyle := WPSTYLE_TILE;
shDesk.SetWallpaperOptions(vWallPOp, 0);
shDesk.ApplyChanges(AD_APPLY_ALL or AD_APPLY_FORCE);
finally
FreeObjectInstance(Pointer(shDesk));
end;
end;
Aqui un ejemplo de uso...
Código Delphi
[-]procedure TForm1.Button1Click(Sender: TObject);
begin
SetDesktopBackgroundImage(ExtractFilePath(Application.ExeName) + 'bmp.bmp');
end;