begin process at 2008 08 29 23:25:10
1 233 930 membres
450 nouveaux aujourd'hui
14 294 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

MODIFIER LE WALLPAPER DE MANIÈRE ALÉATOIRE


Information sur la source

Catégorie :API Niveau : Débutant Date de création : 17/06/2003 Date de mise à jour : 17/06/2003 18:09:23 Vu : 1 973

Note :
9,5 / 10 - par 2 personnes
9,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

Description

Ce code permet de chager votre fond d'écran.

Pour ce faire, mettez vos images (bmp) dans un même répertoire et nommez les par un numéro(1.bmp,2.bmp...).

Enfin mettez le chemin du répertoire en paramètre de l'exe

Source

  • program The_wall;
  • {$APPTYPE CONSOLE}
  • uses
  • sysutils,windows,registry;
  • var
  • chemin,oldbmp : string;
  • SRF : TSearchRec;
  • nbfic,i : integer;
  • begin
  • nbfic:=0;
  • // Détection du parametre sinon fermeture;
  • if paramcount>0 then
  • begin
  • with tregistry.create do
  • try
  • rootkey:=HKEY_CURRENT_USER;
  • if openkey('\Control Panel\Desktop',false) then
  • oldbmp:=readstring('Wallpaper');
  • finally
  • free;
  • end;
  • chemin:=paramstr(1);
  • writeln('recherche des fichiers');
  • // Recherche des fichiers commencant par un numéro
  • if FindFirst(chemin+'\*.bmp',faAnyFile,SRF)=0 then
  • begin
  • if strtointdef(copy(SRF.name,0,1),-1)<>-1 then
  • Inc(nbfic);
  • while findnext(SRF)=0 do
  • begin
  • if strtointdef(copy(SRF.name,0,1),-1)<>-1 then
  • Inc(nbfic);
  • end;
  • // Fonction aléatoire sur ces fichiers
  • randomize;
  • i:=random(nbfic);
  • // Evite de retouver le même fond d'écran
  • while i=strtoint(copy(oldbmp,length(chemin)+2,1)) do
  • i:=random(nbfic);
  • //Affectation du nouveau fond d'écran
  • writeln('Affectation');
  • chemin:=chemin+'\'+inttostr(i)+'.bmp';
  • SystemParametersInfo(SPI_SETDESKWALLPAPER,0,PChar(chemin),SPIF_UPDATEINIFILE);
  • end;
  • end;
  • end.
program The_wall;
{$APPTYPE CONSOLE}
uses
  sysutils,windows,registry;

var
  chemin,oldbmp : string;
  SRF : TSearchRec;
  nbfic,i : integer;
begin
  nbfic:=0;
  // Détection du parametre sinon fermeture;
  if paramcount>0 then
  begin
     with tregistry.create do
     try
        rootkey:=HKEY_CURRENT_USER;
        if openkey('\Control Panel\Desktop',false) then
           oldbmp:=readstring('Wallpaper');
     finally
        free;
     end;
     chemin:=paramstr(1);
     writeln('recherche des fichiers');
     // Recherche des fichiers commencant par un numéro
     if FindFirst(chemin+'\*.bmp',faAnyFile,SRF)=0 then
     begin
        if strtointdef(copy(SRF.name,0,1),-1)<>-1 then
           Inc(nbfic);
        while findnext(SRF)=0 do
        begin
           if strtointdef(copy(SRF.name,0,1),-1)<>-1 then
              Inc(nbfic);
        end;
     // Fonction aléatoire sur ces fichiers
     randomize;
     i:=random(nbfic);
     // Evite de retouver le même fond d'écran
     while i=strtoint(copy(oldbmp,length(chemin)+2,1)) do
         i:=random(nbfic);
     //Affectation du nouveau fond d'écran
     writeln('Affectation');
     chemin:=chemin+'\'+inttostr(i)+'.bmp';
     SystemParametersInfo(SPI_SETDESKWALLPAPER,0,PChar(chemin),SPIF_UPDATEINIFILE);
     end;
  end;
end.
    Aucun commentaire pour le moment.

Ajouter un commentaire

Pub



Appels d'offres

Recherche developpeur ...
Budget : 700€
SITE MARCHAND LOCATION...
Budget : 3 000€
SITE MARCHAND POUR HOTEL
Budget : 4 000€

CalendriCode

Août 2008
LMMJVSD
    123
45678910
11121314151617
18192021222324
25262728293031

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Boutique

Boutique de goodies CodeS-SourceS