怎样在活动桌面下更换墙纸?(100分)

  • 主题发起人 主题发起人 hahabb
  • 开始时间 开始时间
H

hahabb

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样在活动桌面下更换墙纸?
 
systemparametersinfo(SPI_SETDESKWallpaper,0,Nil,SPIF_SendChange);
 
这种方法不能动态更新,必须重新启动后才能生效。
 
那用 SystemParametersInfo(SPI_SETDESKWallpaper,0,'C:/a.bmp',SPIF_SendWinIniChange);
 
获得墙纸
procedure TForm1.Button1Click(Sender: TObject);
var
ADeskTop:IActiveDesktop;
wallpaper:PwideChar;
begin
ADeskTop:=CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
GetMem(wallpaper,128);
ADeskTop.GetWallpaper(wallpaper,128,0);
ShowMessage(string(wallpaper));
FreeMem(wallpaper);
end;
设置墙纸
procedure TForm1.Button1Click(Sender: TObject);
var
ADeskTop:IActiveDesktop;
wallpaper:PwideChar;
begin
ADeskTop:=CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
wallpaper:='d:/2.bmp';
ADeskTop.SetWallpaper(wallpaper,0);
ADeskTop.ApplyChanges(AD_APPLY_ALL);
end;
 
IActiveDesktop是什么?我运行的时候提示未知标识符。
 
uses
ComObj, // For CreateComObject
ShlObj; // For IActiveDesktop
 
CLSID_ActiveDesktop是什么?
 
Who can help me?
 
;CLSID_ShellDesktop: TGUID = (
D1:$00021400; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));

就是com对象的全球唯一标识符Guid啊
 
或者简单点,不用com的话,
永久改变
SystemParametersInfo (SPI_SETDESKWALLPAPER, 0, 'Sample.bmp', SPIF_UPDATEINIFILE);
 
接受答案了.
 

Similar threads

回复
0
查看
738
不得闲
I
回复
0
查看
855
import
I
I
回复
0
查看
512
import
I
后退
顶部