begin process at 2012 02 05 01:57:06
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

API

 > CHANGEMENT AUTOMATIQUE DE L'IMAGE DE L'ARRIÈRE PLAN LORS DU DÉMARAGE DU WINDOWS

CHANGEMENT AUTOMATIQUE DE L'IMAGE DE L'ARRIÈRE PLAN LORS DU DÉMARAGE DU WINDOWS


 Information sur la source

Note :
Aucune note
Catégorie :API Niveau :Initié Date de création :13/09/2002 Date de mise à jour :13/09/2002 19:58:21 Vu / téléchargé :5 177 / 206

Auteur : Ameziane

Ecrire un message privé
Site perso
Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

 Description

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

  • 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.
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.


 Sources de la même categorie

Source avec Zip Source avec une capture KINECT TEST V1 par FFCAST
Source avec Zip DÉCOUPER UNE FENÊTRE par gta126
Source avec Zip TRANSCRIRE UN FICHIER OPEN FINANCIAL EXCHANGE (OFX) EN FICHI... par jeffem
Source avec Zip Source avec une capture MSXML 4.0 VALIDATION XML / XSD par redtux
Source avec Zip FBRENOMMEADOBJET par fbalien

Commentaires et avis

Commentaire de cariboo le 24/02/2003 14:05:56

ici on est sur un site francophone...

Commentaire de Arkko le 06/04/2003 06:28:56

Im not sure you see that but you are on delphi FRANCE ... in french people speak FRENCH !!!

Commentaire de medellelabdesselem le 03/12/2007 21:12:44

merci boucoup mon frere

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,577 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales