Tja.. Ich habe den Code leider nur sozugagen "falschherum" benutzt:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24:
| uses TLHelp32;
...
procedure WindowTitleToEXE(fenstertitel: string; var ergebnis: TStringList); var PID: DWord; aSnapShotHandle: THandle; ContinueLoop: Boolean; aProcessEntry32: TProcessEntry32; begin ergebnis.clear; GetWindowThreadProcessID(FindWindow(nil, PChar(fenstertitel)), @PID); aSnapShotHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0); try aProcessEntry32.dwSize := SizeOf(aProcessEntry32); ContinueLoop := Process32First(aSnapShotHandle, aProcessEntry32); while Integer(ContinueLoop) <> 0 do begin if aProcessEntry32.th32ProcessID = PID then ergebnis.Add(aProcessEntry32.szExeFile); ContinueLoop := Process32Next(aSnapShotHandle, aProcessEntry32); end; finally CloseHandle(aSnapShotHandle); end; |
Und dann der Aufruf:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| procedure TForm1.Button1Click(Sender: TObject); var slist: TStringList; begin slist:=TStringList.Create; try WindowTitleToEXE('Notepad', slist); ListBox1.Items.AddStrings(slist); finally slist.free; end; end; |
Ich schätze man kann den Code auh umschreiben.
Aber du hättest auch ruhig mal bei
dsdt.info oder einfach hier in der Delphi- Suche suchen können...
M!ndbyte
Our force; in mind.