const
cMutexID = '
E-Mailsystem';
var
Mutex : THandle;
HAPPLICATION : HWND;
HMAINFORM : HWND;
StartParams :
String;
CountParams : Integer;
AtomSend : Integer;
begin
dwMessage := RegisterWindowMessage('
{93C5B2B7-CE8D-856B-857B-4CC76F35C091}');
Mutex := CreateMutex(
nil, True, cMutexID);
if (
Mutex <> 0)
and (GetLastError = 0)
then
begin
Application.Initialize;
application.title := '
con.fee E-Mailsystem';
Create_coParams;
Application.CreateForm(TfrmcoDMC, frmcoDMC);
Application.CreateForm(Tfrmsendmail, frmsendmail);
application.showmainform := false;
if not application.Terminated
then
Application.Run;
if (
Mutex <> 0)
then CloseHandle(
Mutex);
end else
begin
HAPPLICATION := 0;
HMAINFORM := 0;
Application.Initialize;
repeat
HAPPLICATION := FindWindowEx(0,HAPPLICATION, '
TApplication', PChar('
Testanwendnung'));
until HAPPLICATION <> Application.Handle;
if HAPPLICATION <> 0
then
begin
Windows.ShowWindow(HAPPLICATION, SW_Normal);
Windows.BringWindowToTop(HAPPLICATION);
Windows.SetForegroundWindow(HAPPLICATION);
HMAINFORM := FindWindowEx(0,0,'
Tfrmmain',
nil);
if (HMAINFORM <> 0)
then
begin
StartParams := '
;';
for CountParams := 1
to ParamCount
do
StartParams := StartParams + '
;' + ParamStr(CountParams);
try
AtomSend := GlobalAddAtom(PChar(StartParams));
finally
GlobalDeleteAtom(AtomSend);
end;
end;
end;
Halt;
end;
end.