Hello, I am Ameziane Rabie. This program let us make our Desktop background image always change every time when Windows starts. You just specify the directory that contains all your pictures and you will have every day a new background picture set automaticaly.
Source / Exemple :
program WallPaper;
uses
SysUtils, FileCtrl, Windows, Registry;
{$R *.RES}
var
Directory, FirstFile: String;
PictureIndex: Integer;
i: Integer;
Info: TSearchRec;
FileFound: Boolean;
Reg: TRegistry;
begin
if ParamCount=2 then
begin
// Windows executes the program when it starts sending tow parameters
Directory:=ParamStr(1);
PictureIndex:=StrToInt(ParamStr(2));
if DirectoryExists(Directory) then
begin
i:=0;
FileFound:=False;
if FindFirst(Directory + '*.bmp', faArchive, Info)=0 then
begin
FirstFile:=info.Name;
// Search of picture file in directory
repeat
Inc(i);
if PictureIndex = i then
begin
FileFound:=True;
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, PChar(Directory+Info.Name), SPIF_UPDATEINIFILE);
if FindNext(Info) = 0 then Inc(PictureIndex) else PictureIndex:=1;
end;
until (FindNext(Info) <> 0) or FileFound;
// Set first picture file existing in directory
// as Wallpaper if index picture doesn't exist
if not FileFound then
begin
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, PChar(Directory+FirstFile), SPIF_UPDATEINIFILE);
PictureIndex:=2;
end;
// Set next picture's index in the Registry Windows
Reg:=TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True) then
Reg.WriteString('WallPaper', ParamStr(0)+' '+Directory+' '+IntToStr(PictureIndex));
finally
Reg.CloseKey;
Reg.Free;
end;
end;
end;
end else
begin
// User executes the program
// Select directory of user's pictures
if SelectDirectory('Select Pictures Directory', '', Directory) then
begin
if Length(Directory)<>3 then Directory:=Directory+'\';
Reg:=TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True) then
Reg.WriteString('WallPaper', ParamStr(0)+' '+Directory+' 1');
finally
Reg.CloseKey;
Reg.Free;
end;
end;
end;
end.
Conclusion :
Compile the source 'WallPaper.dpr' then execute it to select the directory that includes all your Bitmap pictures. Every time when you start Windows you will have new picture on you DeskTop.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.