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

Delphi Discussion :

détecter lancement application


Sujet :

Delphi

  1. #1
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2006
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2006
    Messages : 58
    Points : 46
    Points
    46
    Par défaut détecter lancement application
    Bonjour,

    1- Comment détécter le lancement d'une application sur windows avec delphi ?

    2- Comment mettre une application delphi en arrière plan ?

    Merci,
    Cordialement,
    BALLOUQ Abdessamie.

  2. #2
    Expert éminent sénior

    Avatar de sjrd
    Homme Profil pro
    Directeur de projet
    Inscrit en
    Juin 2004
    Messages
    4 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Suisse

    Informations professionnelles :
    Activité : Directeur de projet
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2004
    Messages : 4 517
    Points : 10 154
    Points
    10 154
    Par défaut
    Merci de ne pas faire de multi-post...

    Ce forum possède des règles que tout utilisateur est tenu de respecter. Merci de faire un effort.
    sjrd, ancien rédacteur/modérateur Delphi.
    Auteur de Scala.js, le compilateur de Scala vers JavaScript, et directeur technique du Scala Center à l'EPFL.
    Découvrez Mes tutoriels.

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 9
    Points : 11
    Points
    11
    Par défaut
    Si tu pouvais être un peu plus clair, on pourrait sûrement t'aider, mais la pour moi c super flou...

  4. #4
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2006
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2006
    Messages : 58
    Points : 46
    Points
    46
    Par défaut Re Explication
    Bonjour,

    Je veux qu'au cours du fonctionnement de mon application, lorsque, par exemple , MS Word est lancé, mon application détecte ce lancement

    Merci

  5. #5
    Membre à l'essai
    Étudiant
    Inscrit en
    Juillet 2005
    Messages
    15
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2005
    Messages : 15
    Points : 17
    Points
    17
    Par défaut
    salut :
    pour détecter le lancement d'une application , la faq delphi du developpeur
    vous donne une solution (elle est telechargeable reponse ) :

    faq delphi >>> interface >>> gestion d'execution >>>> Comment savoir si une application est en cours d'exécution ? ou Comment lancer et contrôler une application extérieure ?

    faq delphi >>> interface >>> gestion d'execution >>>> Comment remettre son application en avant plan ?

    mérci et A+

  6. #6
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 771
    Points
    2 771
    Par défaut
    si par chance waskol passe par ici, il peut nous donnée une idée sur SetWindowsHookEx avec;
    WH_CBT Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application. For more information, see the CBTProc hook procedure.
    bah si il passe
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

  7. #7
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2006
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2006
    Messages : 58
    Points : 46
    Points
    46
    Par défaut Arrière plan et pas Avant
    Bonjour,

    J'ai demandé, comment mettre une application en arrière plan et pas en avant plan.

    Merci

  8. #8
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 771
    Points
    2 771
    Par défaut
    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
     
    program SndRcrdr;
     
    uses
      Forms,
      windows,
      Main in 'Main.pas' {MainForm};
     
    {$R *.res}
     
    begin
     
      SetLastError(NO_ERROR);
      CreateMutex (nil, False, 'MonMutexProject1');
      if GetLastError=ERROR_ALREADY_EXISTS then exit;
      Application.ShowMainForm:=False;//pour caché de la barre
      Application.Initialize;
      Application.CreateForm(TMainForm, MainForm);
      Application.Run;
    end.
     
    //et dans oncreat de ta form principal
    ShowWindow(Application.Handle, SW_Hide);
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

  9. #9
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    On m'a demandé ?

    Pour mettre une application en arrière plan, voui, voui...

    Je regarde de mon coté, je vous tiens informé
    Bidouilleuse Delphi

  10. #10
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 771
    Points
    2 771
    Par défaut
    Citation Envoyé par edam
    si par chance waskol passe par ici, il peut nous donnée une idée sur SetWindowsHookEx avec;
    Citation:
    WH_CBT Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application. For more information, see the CBTProc hook procedure.



    bah si il passe
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

  11. #11
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 771
    Points
    2 771
    Par défaut
    CBTProc

    The CBTProc hook procedure is an application-defined or library-defined callback function that the system calls before activating, creating, destroying, minimizing, maximizing, moving, or sizing a window; before completing a system command; before removing a mouse or keyboard event from the system message queue; before setting the keyboard focus; or before synchronizing with the system message queue. The value returned by the hook procedure determines whether Windows allows or prevents one of these operations. A computer-based training (CBT) application uses this hook procedure to receive useful notifications from the system.

    LRESULT CALLBACK CBTProc(

    int nCode, // hook code
    WPARAM wParam, // depends on hook code
    LPARAM lParam // depends on hook code
    );


    Parameters

    nCode

    Specifies a code that the hook procedure uses to determine how to process the message. This parameter can be one of the following values:

    Value Meaning
    ......
    HCBT_CREATEWND A window is about to be created. The system calls the hook procedure before sending the WM_CREATE or WM_NCCREATE message to the window. If the hook procedure returns a nonzero value, the system destroys the window; the CreateWindow function returns NULL, but the WM_DESTROY message is not sent to the window. If the hook procedure returns zero, the window is created normally.
    At the time of the HCBT_CREATEWND notification, the window has been created, but its final size and position may not have been determined and its parent window may not have been established. It is possible to send messages to the newly created window, although it has not yet received WM_NCCREATE or WM_CREATE messages. It is also possible to change the position in the Z order of the newly created window by modifying the hwndInsertAfter member of the CBT_CREATEWND structure.
    HCBT_DESTROYWND A window is about to be destroyed.
    ......
    If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx.

    wParam
    Depends on the nCode parameter. For details, see the following Remarks section.

    lParam
    Depends on the nCode parameter. For details, see the following Remarks section.
    Return Values
    For operations corresponding to the following CBT hook codes, the return value must be 0 to allow the operation, or 1 to prevent it:
    HCBT_ACTIVATE
    HCBT_CREATEWND
    HCBT_DESTROYWND
    HCBT_MINMAX
    HCBT_MOVESIZE
    HCBT_SETFOCUS
    HCBT_SYSCOMMAND
    For operations corresponding to the following CBT hook codes, the return value is ignored:
    HCBT_CLICKSKIPPED
    HCBT_KEYSKIPPED
    HCBT_QS
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

  12. #12
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Question : C'est la fenètre de ton application que tu souhaites mettre en arrière plan, c'est ça ?

    Bon, de toute façon, si tu veux mettre la Fenêtre de ta propre application en arrière plan :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    Procedure ArrierePlan(AForm:TForm);
    begin
      SetWindowPos(AForm.Handle,HWND_BOTTOM,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE);
    end;
    Exemple :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    begin
    ...
    ArrierePlan(Form1);
    ...
    end;
    en fait, SetWindowPos attend comme premier paramètre, le Handle d'une fenètre, donc si tu as récupéré le Handle de fenètre d'une autre application, ton application peut envoyer cette fenètre en arrière plan.

    C'est ça ce que tu souhaitais ?

    Edit : pour la faire revenir...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    Procedure AvantPlan(AForm:TForm);
    begin
      SetWindowPos(AForm.Handle,HWND_TOP,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE);
    end;
    Bidouilleuse Delphi

  13. #13
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2006
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2006
    Messages : 58
    Points : 46
    Points
    46
    Par défaut Merci bcppppp
    Bonjour tt le monde,

    Merci bcpppppppppppppppppp, en attente de tester vos suggestion.

  14. #14
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    pour la procedure de hook de Edam, comme c'est un Hook système qui est mis en place, il faut mettre ça dans une dll

    Un peu comme ça (je te le dis de suite, je ne sais pas pourquoi ça plante ) :
    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
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    library HookActivation;
     
    uses
      Windows,
      SysUtils,
      Classes;
     
    Type
      TActivationEvent=procedure(var Handle:HWND);
     
    var
      hkFenetre: HHOOK;
      hwFenetre: HWnd ;
     
      ActivationEvent:TActivationEvent;
      SaveDllProc:TDLLProc;
     
    function MonHookProc(Code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
    begin
      Result:= 0;
      if Code<0
      then Result:=CallNextHookEx(hkFenetre, Code, wParam, lParam)
      else  if Code=HCBT_ACTIVATE then
            begin
              hwFenetre:=HWND(wParam);
              if Assigned(ActivationEvent)
              then ActivationEvent(hwFenetre);
            end;
    end;
     
    function ActiveHook:Boolean; stdcall; export;
    begin
      if hkFenetre=0 then
      begin
        hkFenetre:=SetWindowsHookEx(WH_CBT, @MonHookProc, HInstance, 0);
        Result:=True;
      end
      else Result:=False;
    end;
     
    function DesactiveHook: Boolean; stdcall; export;
    begin
      if hkFenetre<>0 then
      begin
        UnHookWindowsHookEx(hkFenetre);
        hkFenetre := 0;
        Result := True;
      end
      else Result := False;
    end;
     
    procedure SetProcedureCallBack(var UneProcedure:TActivationEvent); stdcall; export;
    begin
      ActivationEvent:=UneProcedure;
    end;
     
    procedure LibExit(Reason: Integer);
    begin
      if Reason = DLL_PROCESS_DETACH then
      begin
        // code de sortie de la bibliothèque
        //si on a un hook qui traîne, on le libère...
        DesactiveHook;
      end;
      SaveDllProc(Reason);  // appeler la procédure de point d'entrée enregistrée
    end;
     
    exports
      ActiveHook name 'ActiveHook',
      DesactiveHook name 'DesactiveHook',
      SetProcedureCallBack name 'SetProcedureCallBack';
     
    begin
      hkFenetre:= 0;
      ActivationEvent:=nil;
      // code d'initialisation de la bibliothèque
      SaveDllProc:=DllProc;  // mémoriser la chaîne des procédures de sortie
      DllProc:=LibExit;  // installer la procédure de sortie LibExit
    end.

    Et le Programme Principal :
    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
    62
    63
    64
    65
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
     
    type
      TActivationEvent=procedure(var Handle:HWND);
     
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
     
    procedure ActiveHook; external 'HookActivation.dll';
    procedure DesactiveHook; external 'HookActivation.dll';
    procedure SetProcedureCallBack(var UneProcedure:TActivationEvent); external 'HookActivation.dll';
     
    var
      Form1: TForm1;
      CB:TActivationEvent;
     
    implementation
     
    uses Math;
     
    {$R *.dfm}
     
    procedure MonCallBack(var Handle: Hwnd);
    var buf: array [0..1023] of char;
      Classe: string;
      Titre:string;
    begin
      GetClassName(Handle, buf, sizeof(buf));
      Classe:=string(buf);
      GetWindowText(Handle, buf, sizeof(buf));
      Titre:=string(buf);
      If Form1<>nil then
      If Form1.Memo1<>nil
      then Form1.memo1.lines.Add(Classe+' ---> '+Titre);
    end;
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      CB:=MonCallBack;
      SetProcedureCallBack(CB);
      ActiveHook;
    end;
     
    procedure TForm1.FormDestroy(Sender: TObject);
    begin
      DesactiveHook;
      CB:=nil;
    end;
     
    end.
    Bidouilleuse Delphi

  15. #15
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2006
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2006
    Messages : 58
    Points : 46
    Points
    46
    Par défaut Merci
    Bonjour,

    Merciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii, waskol

  16. #16
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 771
    Points
    2 771
    Par défaut
    salut
    désolé si je remet ce sujet au début, mais j'ai pas volus crée un nouveau;
    pour réparé le code de waskol qui point, l'erreur c'est dans oncreat, car la forme est en train de se crée et déjà il a hooké le message WH_CBT c'est pourqoi il plante car tu utlise le memo avant sa création:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    procedure MonCallBack(var Handle: Hwnd);
    var buf: array [0..1023] of char;
      Classe: string;
      Titre:string;
    begin
      GetClassName(Handle, buf, sizeof(buf));
      Classe:=string(buf);
      GetWindowText(Handle, buf, sizeof(buf));
      Titre:=string(buf);
      If Form1<>nil then
      If Form1.Memo1<>nil
      then Form1.memo1.lines.Add(Classe+' ---> '+Titre);
    end;
    et mem la form1
    en peut aplé les procedure :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    CB:=MonCallBack;
      SetProcedureCallBack(CB);
      ActiveHook;
    dans un autre procedure (message) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    procedure TForm1.MonMessage;
    begin
      if not InitialisationHook(Handle) then
        begin
          Sleep(100);
          PostMessage(Handle,WM_Jamai,0,0);
        end;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
        Timer1.Enabled:=false;
        PostMessage(Handle,WM_Jamai,0,0);
       //initialise le hook en faisant passer le handle de Form1 en paramètre
    end;
    j'ai "bricolé" un code de hook WH_CBT d'aprés 2 code:
    http://www.phidels.com/php/index.php...ip.php3&id=547
    et
    http://www.phidels.com/php/index.php...ip.php3&id=349
    pour arrété les IE, Fenetre de "gestionnére des taches de windows" et...
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

  17. #17
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Génial !!! Super Edam est passé par là !!!!
    Bidouilleuse Delphi

  18. #18
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 771
    Points
    2 771
    Par défaut
    oh, pas du tt, je suis qu'un simple bricoleur,
    a propos; j'ai pas touvé le sujet ou tu parle de modifier les API, bien sur il y a un autre delphinaute qui déjà creusé le sujet et je sais pas où
    c'est pour http://www.developpez.net/forums/sho...d.php?t=188758, car je suis intérésé par les ports série et c'est vraiment intéréssen, surtout si en peut "hooké" le cratFichier
    PAS DE DESTIN, C'EST CE QUE NOUS FAISONS

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

Discussions similaires

  1. Lancement application à partir Browser
    Par MALAGASY dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 26/10/2005, 10h47
  2. Pb lancement application extérieure
    Par christellel198 dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 14/10/2005, 15h01
  3. [vb][excel][MSPROJECT] lancement application
    Par mulanzia2003 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 28/09/2005, 11h18
  4. Fermeture et delay de lancement application sur dos
    Par jason59 dans le forum Windows
    Réponses: 5
    Dernier message: 18/09/2005, 20h01
  5. [NetBeans] [4.1] lancement application
    Par hutchuck dans le forum NetBeans
    Réponses: 11
    Dernier message: 31/08/2005, 22h59

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