Bonjour,
Je suis sur un service Windows ecrite en delphi.
La particularité de ce service , c'est un serveur de clé de protection réseau, elle peux afficher sa modale en tant que service Windows.
J'ai écrit en delphi un mini-appli console qui permet d'appeler (afficher) la modale de ce service, ça à l'air de marcher.
Je suis connecté en tant qu'utilisateur nommé "admin" non limité.
Le probléme : c'est quand je me change d'utilisateur sur un utilisateur limitée "limituser" , et que j'execute le mini-appli qui affiche la modale du service , la modale vient finalement s'afficher sur le bureau de l'utilisateur admin (sans être deloguer).
Code du petit mini-appli :
Dans le service , c'est un thread qui permet d'afficher la modale :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 begin he:=OpenEvent(EVENT_ALL_ACCESS,FALSE,'Global\showsc'); if (he<>0) then begin SetEvent(he); //ExitProcess(1); end; end.
Comment faire pour que la modale s'affiche ,quelque soit l'utilisateur ?
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 function thmodal(p : pointer) : DWORD; stdcall; var sd : array[1..SECURITY_DESCRIPTOR_MIN_LENGTH] of byte; sa : TSECURITYATTRIBUTES; he : thandle; bw : dword; app : Tapplication; begin sa.nLength := sizeof(sa); sa.bInheritHandle := TRUE; sa.lpSecurityDescriptor := @sd; InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(@sd, TRUE, nil, FALSE); he:=CreateEvent(@sa,FALSE,FALSE,'Global\Showsc'); while (isserviced) do begin bw:=WaitForSingleObject(he,2500); if bw=WAIT_OBJECT_0 then begin ResetEvent(he); app := tapplication.Create(nil); App.CreateForm(TPrincipale, Principale); App.CreateForm(Tflog, flog); App.CreateForm(Tfstat, fstat); App.CreateForm(Tfuser, fuser); Principale.Showmodal; App.Destroy; end; end; thmodal := 1; end; procedure TService_license_server.ServiceStart(Sender: TService; var Started: Boolean); var tmp : array[0..512] of char; dwid : cardinal; begin started := true; isserviced := true; CreateThread(nil,0,@thmodal,nil,0,dwid); end;
Merci
Partager