Autor Beitrag
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 17:34 
Hallo zusammen..also ich versuchs mal hier

Ich habe ein Hauptprogramm woraus andere Programme Gestartet werden (über Buttons).
Diese programme sollen nur vom Hauptprogramm aus gestartet werden.
ich möchte also verhindern das jemand ein programm über die ***.exe startet.
Ich hab hier schon gestöbert und nen paar beiträge dazu gefunden komme damit aber nich klar weil die
irgendwelche Kenntisse vorraussetzen die ich noch nicht habe.
Veilleicht hat ja jemand ne leicht verständliche Lösung.

Danke im vorraus
Andre
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: Mi 08.03.06 17:39 
Gucken ob die exe läuft und wenn sie im Task-Manager steht dann Peng - tot ist sie. Einfach mit killtask abschießen.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 17:45 
user profile iconMarco D. hat folgendes geschrieben:
Gucken ob die exe läuft und wenn sie im Task-Manager steht dann Peng - tot ist sie. Einfach mit killtask
abschießen.


Danke für die Flinke Antwort...würde das ganze gerne Programmtechnisch lösen.
Hast du vielleicht nen bischen Code für mich :wink:
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: Mi 08.03.06 17:50 
Lad dir bei www.dsdt.info den EasyHelper. Dort findet du die Funktionen, die du brauchst (IsExeRunning und KillTask).

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 18:02 
user profile iconMarco D. hat folgendes geschrieben:
Lad dir bei www.dsdt.info den EasyHelper. Dort findet du die Funktionen, die du brauchst (IsExeRunning und KillTask).


Cool Danke
Funktioniert soweit ....UNTER XP...
Unter WIN 2000 läuft die TlWin32 nicht
in unserer Firma laufen aber Rechner mit XP und andere mit Win2000.

gibt es noch ne andere Lösung ?
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: Mi 08.03.06 18:03 
user profile iconder Berliner hat folgendes geschrieben:
Unter WIN 2000 läuft die TlWin32 nicht

Was ist denn TlWin32 ? :shock:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 18:19 
user profile iconMarco D. hat folgendes geschrieben:
user profile iconder Berliner hat folgendes geschrieben:
Unter WIN 2000 läuft die TlWin32 nicht

Was ist denn TlWin32 ? :shock:


Das Ding muß man in die Uses einbinden.
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: Mi 08.03.06 18:22 
Komisch :nixweiss: Bist du dir sicher, dass das so heißt?
Bei mir heißt das TlHelp32.
Zitat:

Die Unit TLHelp32 führt normalerweise ein unerkanntes Schattendasein in der RTL. Es stecken jedoch sehr viele nützliche Funktionen in ihr. Unter anderem können wir auch herausfinden, welche Exe-Datei hinter einem Fensterhandle steckt.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 18:29 
user profile iconMarco D. hat folgendes geschrieben:
Komisch :nixweiss: Bist du dir sicher, dass das so heißt?
Bei mir heißt das TlHelp32.


Ooops sorry ...richtig gelesen, falsch geschrieben

hast recht..
aber auch die funktioniert unter Win200(NT) nicht.

Moderiert von user profile iconChristian S.: Quote-Tag repariert
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 08.03.06 19:37 
Geht eigentlich relativ einfach und dabei sogar sehr Täuschungssicher:

Es gibt eine API-Funktion GetStartupInfo(A\W), mit de man einige Informationen über seinen eigenen Prozess abfragen kann, u.a. auch, aus welchem Prozess heraus man selbst gestartet wurde. Diese Information ermittelt man einfach und löst den Pfadnamen entsprechend auf. Danach muss einfach nur noch die Prüfsumme seinen Aufrufers mit einem Referenzwert (dem vom Original) verglichen werden. --> Unterschied = falsches Programm --> Mit Halt-Befehl beenden ;-)

Diese Möglichkeit ging IIRC auch über die TlHelp32 zu implementieren, einfacher ist aber der Weg über GetStartupInfo.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 19:51 
user profile iconBenBE hat folgendes geschrieben:
einfacher ist aber der Weg über GetStartupInfo.


Hallo...@BenBE
Hört sich gut an ..kennst du vielleicht noch ne seite vo diese Funktion erklärt wird...
bzw. ich bräuchte Hilfe wie man sie einsetzt. :flehan:
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 08.03.06 20:32 
Die Grundlegenden Informationen zur genannten Funktion gibt es im MSDN.

Allgemein sieht das immer etwa so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var SI: TStartupInfo;

FillChar(SI, #0, SizeOf(TStartupInfo);
SI.cbSize := SizeOf(TStartupInfo);

SetLastError(0);
GetStartupInfo(SI);

If GetLastError <> 0 Then
    Raise Exception.Create('Fehlgeschlagen');

//SI enthält gültige Informationen


Wobei ich aber grad nochmal nachgeguckt hab: In den StartupInfos steht alles Mögliche drin, nur nicht, was man wirklich wissen will.

Konnte soweit nur ein VBScript finden: msdn.microsoft.com/l...mi/win32_process.asp
Da ich mit den WMI's aber noch nicht gearbeitet hab, kann ich da aber leider keine Übersetzung für geben.
Unter msdn.microsoft.com/l...ication_examples.asp gibt's aber nen C++-Source ...

Aber eventuell kenn ja jemand noch ne Möglichkeit, wie man das ohne WMI machen kann. Wird es sicherlich ne API geben, die einem das zurückgibt ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 20:52 
@BenBe

Danke erstmal für die Mühe..
Aber ich glaube mit GetStartupInfo Komme ich nicht klar.
So viele Infos und ich weiß nich welche ich für mein Prob Brauche.

Ich Versuchs nochmal zu erkären

Über ein Startprogramm sollen mehrere Anwendungen gestartet werden können.
Die einzelnen Anwendungen sollen jedoch nicht per klick auf ihre ***.exe Datei gestartet werden.
Falls das doch jemand Versucht Soll nicht die Anwendung starten sondern das Startprogramm.
In meiner Firma Läuft das Ganze in nem Netztwerk.

puhh...viel text für ein kleines Prob.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 08.03.06 21:01 
Hab nochmal kurz geguckt:

Auch wenn's abwegig aussieht: www.delphi-forum.de/....php?p=249034#249034 ist eigentlich absolut genial in der Hinsicht:

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:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
uses
  Tlhelp32

function VerifyCallingProcess: Boolean;;
const
  PROCESS_TERMINATE = $0001;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;

  ParentProcess: THandle; //Handle des Parent-Prozesses

begin
  Result := false;

  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);

  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  ParentProcess := 0; //Default
  while Integer(ContinueLoop) <> 0 do
  begin
    if FProcessEntry32.th32ProcessId = GetCurrentProcessId then
    Begin
      // FProcessEntry32.th32ParentProcessID enthält die ProcessID des Parent-Prozesses
      ParentProcess := FProcessEntry32.th32ParentProcessID;

      Break;
    end;
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);

  If ParentProcess = 0 Then
    Exit;

  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);

  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  while Integer(ContinueLoop) <> 0 do
  begin
    if FProcessEntry32.th32ProcessId = ParentProcess then
    Begin
      // Überprüfungen ausführen und ggf. mit Halt das eigene Programm killen.
      Break;
    end;
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);

  Result := True; //Wir waren erfolgreich...
end;


HTH. Ist etwas komplizierter geworden, als ich das in erinnerung hatte ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: Mi 08.03.06 21:06 
Da ist sie wieder die ---TlHelp32----

Das funktioniert gut unter WinXp aber unter Win2000(NT) Gehts nich.
Bei NT schein die TlHelp irgenwie nich eigebunden zu sein.

Danke Trotzdem.