[Delphi] CreateProcess + Events toevoegen aan app

Pagina: 1
Acties:

  • Guillome
  • Registratie: Januari 2001
  • Niet online
Hoi, ik start met CreateProcess bijv. notepad op.
Hoe kan ik dan een acite aan de onminimize of de onclose event toevoegen.
Dus als ie minimaliseerd, dat ik dan een message ofzo terug krijg?

Dit is mijn code
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
Function TForm1.StartFile(Str : String) : Integer;
var PCharArr:PChar;
    pInfo:Process_Information;
    sInfo:StartupInfo;
begin
  PCharArr := AllocMem(SizeOf(Char)*(Length(Str)+7));
  try
    FillChar (sInfo, SizeOf (sInfo), 0);
    sInfo.cb := SizeOf (sInfo);    with sInfo do
    begin
    cb := SizeOf(TStartupInfo);
    dwFlags := startf_UseShowWindow;
    wShowWindow := SW_HIDE;
    end;
    CreateProcess(nil,StrPCopy(PCharArr,(Str)),nil,nil,FALSE,0,nil,nil,sInfo,pInfo);
  finally
    freemem(PCharArr);
  end;
  Result := pInfo.dwThreadId;
End;

function TForm1.ShowInstance(Pid : Integer) : Boolean;
  function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
  begin
    Result:=lParam=1234;
    if Result then
    ShowWindow(hWnd, SW_SHOWNORMAL);
  end;
begin
  EnumThreadWindows(Pid, @EnumWindProc, 1234);
End;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ListBox1.Items.Add(IntToStr(StartFile('notepad.exe')));
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  ShowInstance(StrToInt(ListBox1.Items[ListBox1.ItemIndex]));
end;

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


Verwijderd

Een systemwide hook zetten en kijken of er iets voor de hwnd's in het door jou gecreeerde process langs komt? iets anders weet ik ook eigenlijk zo snel niet te verzinnen.

  • Guillome
  • Registratie: Januari 2001
  • Niet online
Juist ja :)
Hoe ongeveer? Ik wil het zelf wel uitzoeken, maar een klein beginnetje?

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


Verwijderd

hmmz volgens mij als je SetWindowsHookEx en EnumThreadWindows 'n beetje handig combineerd moet je wel 'n aardig eindje komen?

Verwijderd

voorbeeld system hook: hier

  • Guillome
  • Registratie: Januari 2001
  • Niet online
Tnx jongens!! :D

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router

Pagina: 1