바탕화면에 그림을 띠울려고 하는데 안되네요
조규춘님이 가르쳐 주실걸로 했는데도 안되요
그래서 또 질문을 드립니다.
에러는 없네요.
디스플레이 정보에 가면 바뀌어는 있는데 바탕화면에는 없네요.
뭐가 잘못 된건지 도통 모르겠네요.
부탁합니다.한번 봐 주세요.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Registry,Winprocs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
WPS_Tile = 0; //바둑식 배열
WPS_Center = 1; //가운데
WPS_SizeToFit = 2; //늘리기
WPS_XY = 3; //x, y위치에 그리기
implementation
{$R *.DFM}
procedure SetWallpaperExt(sWallpaperBMPPath : string; nStyle, nX, nY :
integer );
var
reg : TRegIniFile;
s1 : string;
X, Y : integer;
begin
reg := TRegIniFile.Create('Control PanelDesktop' );
with reg do
begin
s1 := '0';
X := 0;
Y := 0;
case nStyle of
WPS_Tile : s1 := '1';
WPS_Center: nStyle := WPS_Tile;
WPS_XY :
begin
nStyle := WPS_Tile;
X := nX;
Y := nY;
end;
end;
WriteString( '', 'Wallpaper', sWallpaperBMPPath );
WriteString( '', 'TileWallpaper',s1 );
WriteString( '', 'WallpaperStyle', IntToStr( nStyle ) );
WriteString( '', 'WallpaperOriginX', IntToStr( X ) );
WriteString( '', 'WallpaperOriginY', IntToStr( Y ) );
end;
reg.Free;
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Nil, SPIF_SENDWININICHANGE );
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetWallpaperExt('c:windows11.bmp',WPS_XY,10,200);
end;
end.
procedure TForm1.Button1Click(Sender: TObject);
begin
if not SystemParametersInfo(SPI_SETDESKWALLPAPER,0,
pChar('c:windowsnewwallpaper.bmp'),
SPIF_UPDATEINIFILE or SPIF_SENDWININICHANGE) then
ShowMessage(SyserrorMessage(GetlastError()));
end;
혹시나 active desktop 사용하시면 아래와 같이 하셔야 되는걸로 알고 있읍니당.
procedure ChangeActiveWallpaper;
const
CLSID_ActiveDesktop: TGUID = '{75048700-EF1F-11D0-9888-006097DEACF9}';
var
ActiveDesktop: IActiveDesktop;
begin
ActiveDesktop := CreateComObject(CLSID_ActiveDesktop)
as IActiveDesktop;
ActiveDesktop.SetWallpaper('c:windowsprofilesdavedesktopfern.jpg', 0);
ActiveDesktop.ApplyChanges(AD_APPLY_ALL or AD_APPLY_FORCE);
end;