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.
Version imprimable
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.
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.
Si tu pouvais être un peu plus clair, on pourrait sûrement t'aider, mais la pour moi c super flou...
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
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+;)
si par chance waskol passe par ici, il peut nous donnée une idée sur SetWindowsHookEx avec;bah si il passe:lol: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.
Bonjour,
J'ai demandé, comment mettre une application en arrière plan et pas en avant plan.
Merci
Code:
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);
On m'a demandé ? ;)
Pour mettre une application en arrière plan, voui, voui...:aie:
Je regarde de mon coté, je vous tiens informé :mrgreen:
Citation:
Envoyé par edam
Citation:
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
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 :
Exemple :Code:
1
2
3
4
5 Procedure ArrierePlan(AForm:TForm); begin SetWindowPos(AForm.Handle,HWND_BOTTOM,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE); 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.Code:
1
2
3
4
5 begin ... ArrierePlan(Form1); ... end;
C'est ça ce que tu souhaitais ?:P
Edit : pour la faire revenir...:mrgreen:
Code:
1
2
3
4
5 Procedure AvantPlan(AForm:TForm); begin SetWindowPos(AForm.Handle,HWND_TOP,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE); end;
Bonjour tt le monde,
Merci bcpppppppppppppppppp, en attente de tester vos suggestion. ;)
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 :aie:) :
Code:
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:
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.
Bonjour,
Merciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii, ;) waskol
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:
et mem la form1Code:
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;
en peut aplé les procedure :dans un autre procedure (message) :Code:
1
2
3 CB:=MonCallBack; SetProcedureCallBack(CB); ActiveHook;
j'ai "bricolé" :lol: :lol: un code de hook WH_CBT d'aprés 2 code:Code:
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;
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... :lol: :lol:
Génial !!! Super Edam est passé par là !!!!:P
:oops: :oops: 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 :lol: