IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

Utilisation de FindWindow


Sujet :

Langage Delphi

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 3
    Points : 2
    Points
    2
    Par défaut Utilisation de FindWindow
    Bonjour a tous ,
    Voila mon problème je voudrais crée un trainer pour "FarCry 2" mais la source ne trouve pas le programme lancé.
    Le "findwindow" ne trouve pas le programme lancé ???
    Voici mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    var
      Form1: TForm1;
      myHandle: HWND;
    implementation
     
    {$R *.dfm}
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
        myHandle := FindWindow('Far Cry 2',nil);
    if myHandle > 0 then
        ShowMessage('Jeu FarCry2 lancé')
    else
        ShowMessage('Jeu FarCry2 non trouvé');
     
    end;
     
    end.
    Merci de vos réponses et bonne programmation

  2. #2
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Salut

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    //Syntax
     
    HWND FindWindow(          
        LPCTSTR lpClassName,
        LPCTSTR lpWindowName
    );
    Tu dois préciser à FindWindow l'un ou l'autre des paramètres. Le 1° étant le nom de la classe de la fenêtre, et le 2° étant son intitulé ou titre (Window's tiltle).

    'Far Cry 2' ressemble plus au titre de la fenêtre qu'à un nom de classe.

    @+ Claudius.

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 3
    Points : 2
    Points
    2
    Par défaut
    Ben merci a toi lol ,mais étant débutant , j'ai rien compris lol

    La fenêtre du jeu est "Far Cry 2" et l'executable est "farcry2.exe"

    Merci a toi de ta réponse .

  4. #4
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Je te suggérais d'inverser les paramètres.

    Essaye myHandle := FindWindow(nil, 'Far Cry 2'); et regarde si tu récupères le Handle.

    @+

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 3
    Points : 2
    Points
    2
    Par défaut Merci a toi
    ca fonctionne nickel ,un grand merci a toi

    voici mon code ,qui peu servir pour d'autres :
    ( Sous Delphi 7 et XP sp3)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls, jpeg, MPlayer;
     
    type
      TForm1 = class(TForm)
        Image1: TImage;
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Button1: TButton;
        StaticText1: TStaticText;
        Image2: TImage;
        Button2: TButton;
        Image3: TImage;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
      myHandle : integer;
    implementation
     
    {$R *.dfm}
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
       StaticText1.caption := 'c est bon' ;
       Image2.Visible := true ;
       Image3.Visible := False ;
       end;
     
    procedure TForm1.Button2Click(Sender: TObject);
    begin
       StaticText1.caption := 'Jeu non lancé ' ;
       Image2.Visible := False ;
       Image3.Visible := True ;
    end;
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    myHandle := FindWindow(nil, 'Far Cry 2');
    if myHandle > 0 then
        ShowMessage('Jeu FarCry2 lancé')
    else
        ShowMessage('Jeu FarCry2 non trouvé');
     
    end;
     
    end.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VBA] Utilisation API FindWindows
    Par idir.17 dans le forum Général VBA
    Réponses: 5
    Dernier message: 28/03/2007, 14h39
  2. utiliser les tag [MFC] [Win32] [.NET] [C++/CLI]
    Par hiko-seijuro dans le forum Visual C++
    Réponses: 8
    Dernier message: 08/06/2005, 15h57
  3. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 12h36
  4. [BCB5] Utilisation des Ressources (.res)
    Par Vince78 dans le forum C++Builder
    Réponses: 2
    Dernier message: 04/04/2002, 16h01
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo