poc3796
asked on
SystemParametersInfo
I write a program that change windows desktop using
SystemParametersInfo(SPI_S ETDESKWALL PAPER, 0, 0, Pchar('Bitmap.Bmp'), SPIF_SENDWININICHANGE)
This work when I execute the program from Delphi IDE but if I execute it from menu this return ErrorCode 2
SystemParametersInfo(SPI_S
This work when I execute the program from Delphi IDE but if I execute it from menu this return ErrorCode 2
Try this......
SystemParametersInfo(SPI_S ETDESKWALL PAPER, 0, 0, Pchar('C:\windows\desktop\ YourFolder \Bitmap.Bm p'),
SPIF_SENDWININICHANGE);
if it still isn't working try this.....
SystemParametersInfo(SPI_S ETDESKWALL PAPER, 0, 0, Pointer('C:\windows\deskto p\YourFold er\Bitmap. Bmp'),
SPIF_SENDWININICHANGE);
SystemParametersInfo(SPI_S
SPIF_SENDWININICHANGE);
if it still isn't working try this.....
SystemParametersInfo(SPI_S
SPIF_SENDWININICHANGE);
If you have saved the project and the bitmap is in your folder then you can use Bitmap.bmp
if you haven't saved the project and you are trying to do Bitmap.bmp it is looking in the Delphi folder and isn't finding the bitmap...so you need to extended and give the exact path to the bitmap.....
Regards,
Viktor Ivanov
if you haven't saved the project and you are trying to do Bitmap.bmp it is looking in the Delphi folder and isn't finding the bitmap...so you need to extended and give the exact path to the bitmap.....
Regards,
Viktor Ivanov
ASKER
with Pointer cluase the program is not compiled, and the strange thing is that
SystemParametersInfo(SPI_S ETDESKWALL PAPER, 0, Pchar('Bitmap.Bmp'), SPIF_SENDWININICHANGE)
WORK in IDE .....
SystemParametersInfo(SPI_S
WORK in IDE .....
Why don't you try this........
---------------------
uses Windows, registry;
procedure SetWallPaper(sWallpaperBMP Path : String; bTile : Boolean);
var
reg : TRegIniFile;
begin
reg : TRegIniFile.Create('Contro l Panel\Dekstop');
with reg do
begin
WriteString('', 'Wallpaper', sWallpaperBMPPath);
if bTile then
begin
WriteString('', 'TileWallpaper', '1');
end
else
begin
WriteString('', 'TileWallpaper', '0');
end;
end;
reg.Free;
SystemParametersInfo(SPI_S ETDESKWALL PAPER, 0, Nil, SPIF_SENDWININICHANGE);
end;
Example Call : SetWallpaper('C:\Windows\d esktop\MyB itmap.bmp' , False);
--------------
Regards,
Viktor Ivanov
---------------------
uses Windows, registry;
procedure SetWallPaper(sWallpaperBMP
var
reg : TRegIniFile;
begin
reg : TRegIniFile.Create('Contro
with reg do
begin
WriteString('', 'Wallpaper', sWallpaperBMPPath);
if bTile then
begin
WriteString('', 'TileWallpaper', '1');
end
else
begin
WriteString('', 'TileWallpaper', '0');
end;
end;
reg.Free;
SystemParametersInfo(SPI_S
end;
Example Call : SetWallpaper('C:\Windows\d
--------------
Regards,
Viktor Ivanov
ASKER
I drag & drop your procedure in my program but this don't work also in IDE [but this is compiled].
I try this:
procedure TForm1.Button1Click(Sender : TObject);
var cString: String;
begin
cString := 'D:\temp\sfondo2.BMP';
if FileExists( cString ) then
if not( SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, Pchar( cString ), SPIF_SENDWININICHANGE) ) then
MessageBox( 0, PChar( Format( '%d', [GetLastError()] )), 'Errore', MB_OKCANCEL + MB_DEFBUTTON1);
end;
procedure TForm1.Button2Click(Sender : TObject);
var cString: String;
begin
SetWallPaper( 'D:\DOWNLOAD\SFONDI~1\mana b0~1.BMP', False );
end;
// *------------------------- ---------- ---------- ---------- ---------- ---------
procedure SetWallPaper(sWallpaperBMP Path : String; bTile : Boolean);
var
reg : TRegIniFile;
begin
reg := TRegIniFile.Create('Contro l Panel\Dekstop');
with reg do
begin
WriteString('', 'Wallpaper', sWallpaperBMPPath);
if bTile then
begin
WriteString('', 'TileWallpaper', '1');
end
else
begin
WriteString('', 'TileWallpaper', '0');
end;
end;
reg.Free;
SystemParametersInfo(SPI_S ETDESKWALL PAPER, 0, Nil, SPIF_SENDWININICHANGE);
end;
Bottom1Click work in IDE evironment
Bottom2Click don't work at all
regards
poc3796
I try this:
procedure TForm1.Button1Click(Sender
var cString: String;
begin
cString := 'D:\temp\sfondo2.BMP';
if FileExists( cString ) then
if not( SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, Pchar( cString ), SPIF_SENDWININICHANGE) ) then
MessageBox( 0, PChar( Format( '%d', [GetLastError()] )), 'Errore', MB_OKCANCEL + MB_DEFBUTTON1);
end;
procedure TForm1.Button2Click(Sender
var cString: String;
begin
SetWallPaper( 'D:\DOWNLOAD\SFONDI~1\mana
end;
// *-------------------------
procedure SetWallPaper(sWallpaperBMP
var
reg : TRegIniFile;
begin
reg := TRegIniFile.Create('Contro
with reg do
begin
WriteString('', 'Wallpaper', sWallpaperBMPPath);
if bTile then
begin
WriteString('', 'TileWallpaper', '1');
end
else
begin
WriteString('', 'TileWallpaper', '0');
end;
end;
reg.Free;
SystemParametersInfo(SPI_S
end;
Bottom1Click work in IDE evironment
Bottom2Click don't work at all
regards
poc3796
ASKER
Excuse me in the fast try that I do I don't see that you write DEKSTOP other than DESKTOP when I correct your code work well
Repost an answer and I accept it
Excuse me
Repost an answer and I accept it
Excuse me
ASKER
Excuse me in the fast try that I do I don't see that you write DEKSTOP other than DESKTOP when I correct your code work well
Repost an answer and I accept it
Excuse me
Repost an answer and I accept it
Excuse me
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ErrorCode=2 means "File not found" or something like that, I think. But I'm not sure.
Regards, Madshi.