Autor Beitrag
koller1
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 216

WIN XP
D7 Ent
BeitragVerfasst: Mi 12.10.05 14:40 
Nehmen wir mal an, ich starte ein Prog mit dem Namen Project1.exe zweimal. Nun will ich aber eine Prozess mit dem Namen Project1.exe abschießen per killtask(). Welcher dieser gleichnamigen Prozesse wird zuerst beendet? Der der später gestartet wurde, oder welcher?

MFG
koller1

_________________
PLEASE INSERT SYSTEM DISK AND PRESS ENTER!
Und wenn du nicht gestorben bist, presst du noch heute! ;)
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mi 12.10.05 15:45 
kommt drauf an wie das killtask seine liste verwaltet, z.b. sortiert nach PID oder gar nicht.
am einfachsten probierst du es aus ;)

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 14.10.05 12:21 
Titel: asd
Hallo koller1,

du kanst doch bei oncreate prüfen, ob der Prozessname schon läuft und wenn dann kannst du doch wieder 'close' machen :wink:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 0 to prozessliste.count-1 do
begin
if prozessliste.strings[i]=application.exename then close;
end;


Vorher noch in die stringlist 'prozessliste' mit der funktion 'getprocesslist' ausm Easy Helper die Prozessliste einfügen.

CU KOLLER

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
hallo
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 450

WIN XP, SuSE 9.3
D3 Prof, D6 Pers, 2005 Pers
BeitragVerfasst: Fr 14.10.05 13:58 
Am besten ist es, wenn du dir selbst eine Funktion schreibst!
Dann musst du dir einfach nur merken welche PID zu welcher Startzeit gehört, und dann kannst du den richtigen "abschießen"

_________________
Der beste je Programmierte Trojaner: Windows XP
Wäre es nicht adequat, den Usus heterogener Termini zu minimieren?
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 14.10.05 14:21 
wenn die liste mit Process32First/Next erstellt wird und die schleife nicht bei einem Fund beendet wird, werden alleProzese mit dem Namen gekillt, ansonsten nur der Prozesss mit der niedirgeren ProzesssID (ersgestartete)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 14.10.05 15:23 
Titel: asd
@ ual@ogc:

Kannst du das nochmal etwas einfacher erklären?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 14.10.05 15:26 
Die KillTask funktion von swissdelphicenter.ch schließ alle prozesse mit dem namen. hat man 2 mal project1.exe werden beide prozesse beendet

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 15.10.05 12:17 
Titel: as
Also ohne killtastk könnte es vielleicht so gehen:

ausblenden volle Höhe 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:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
uses
 tlhelp32;

procedure GetProcessList(const aProcessList: TStrings);
var
  Snap: THandle;
  ProcessE: TProcessEntry32;
begin
  aProcessList.Clear;
  Snap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  try
    ProcessE.dwSize := SizeOf(ProcessE);
    if Process32First(Snap, ProcessE) then
      Repeat
        aProcessList.Add(ProcessE.szExeFile);
      Until not Process32Next(Snap, ProcessE)
    else
      RaiseLastOSError;
  finally
    CloseHandle(Snap);
  end;
end;

function alreadyRunning : boolean;
var list:tstringlist; i:integer;
begin
list:=tstringlist.create;
getprocesslist(list);
for i := 0 to list.count-1 do
begin
if list.strings[i]=application.exename then result:=true;
end;

end;

//Aufruf bei oncreate
if alreadyrunning = true then close;


Ich weiß nich ob das funzt. Sollte es aber :wink:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot