Autor Beitrag
barana
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: So 22.04.07 23:31 
Hallo Leute,

ich würde gerne ein Programm schreiben, welches nur einmal Aufrufbar ist. Dazu habe ich bereits einige Units gefunden und komme damit klar.

Ich benutze folgende Unit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
unit NurEinmal; // zur Benutzung nur diese Unit einbinden

interface

implementation

uses windows, sysutils, forms;
var mHandle: THandle;

initialization
mHandle := CreateMutex(nil, True, PChar(application.title));
if GetLastError = ERROR_ALREADY_EXISTS then
begin
application.Terminate;
halt;
end;

finalization
if mHandle <> 0 then CloseHandle(mHandle)

end.


Jetzt würde ich aber gerne eine Funktion basteln, die dem vorher aufgerufenen Programm eine Message schickt. Ich weis nicht inwiefern sowas realisierbar ist, aber ich würde sogar gerne eine bestimmte Funktion oder besser gesagt ein Ereignis über PostMessage aufrufen.
Sagen wir also, dass man das Programm zum zweiten mal startet. Dann müsste folgendes passieren:
-das erste Programm wird ausfindig gemacht
-PostMessage an das erste Programm zum starten des OnCreate Ereignisses als Besispiel

Ist sowas möglich? Wenn ja, wie?

Danke im Voraus
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 22.04.07 23:39 
Moin!

Schonmal in die Suche geschaut? Suche in: Delphi-Forum, Delphi-Library MUTEX hätte u.A. auch diesen Link hier ausgespuckt ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mo 23.04.07 00:59 
user profile iconbarana hat folgendes geschrieben:
Hallo Leute,

ich würde gerne ein Programm schreiben, welches nur einmal Aufrufbar ist. Dazu habe ich bereits einige Units gefunden und komme damit klar.


Copy-and-paste-Programmierer :nut:

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mo 23.04.07 07:49 
Und Du bist so :autsch: und erarbeitest Dir alles selbst? :gruebel:

:zwinker:

_________________
Na denn, dann. Bis dann, denn.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 23.04.07 08:36 
Alternativ kann ich auch die Unit OneInst empfehlen. Die gibts auf Luckies Seite. Sehr schön, und sehr einfach zu benutzen.

_________________
We are, we were and will not be.
barana Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mo 23.04.07 13:52 
user profile iconNarses hat folgendes geschrieben:
...diesen Link hier ausgespuckt ;)

cu
Narses



Ja genau das hab ich gesucht... Danke!