begin process at 2010 02 10 13:46:23
  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é :4 289 / 194

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 NEXTGENS -> UNITÉS DE TYPES ÉVOLUÉS NOUVELLE GÉNÉRATION (DE... par f0xi
Source avec Zip Source avec une capture AUTO-COMPLÉTION D'UN CONTRÔLE DE SAISIE par Bacterius
Source avec Zip CARDS GAME SDK 1.0.0.0 par f0xi
Source avec Zip Source avec une capture TRAYICON - VOTRE ICONE DANS LA BARRE DES TACHES par Bacterius
Source avec Zip Source avec une capture WINHIDER _ CACHER UN PROGRAMME DE L'ÉCRAN ET DE LA BARRE DE ... par soldier8514

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


HTC Hero

Entre 550€ et 550€

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
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,374 sec (4)

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