Einzelnen Beitrag anzeigen

dust258

Registriert seit: 18. Aug 2008
62 Beiträge
 
#2

Re: Mal wieder: Doppeltes starten einer Anwendung unterbinde

  Alt 11. Feb 2010, 11:56
Kennt Ihr das: In DEM MOMENT in dem ich hier den Thread abgesendet habe finde ich die Lösung
Danke fürs Kopfzerbrechen, ich musste nur "FindWindow('TListStatSchnittForm', nil);" nutzen ^^

Delphi-Quellcode:
{$R *.res}

  const
    MutexName = 'ErweiterteListen';
  var
    hMutex: THandle;
  NextHandle: Hwnd;
  foundedHandle : Hwnd;
  NextTitle: array[0..260] of char;
  foundHandle : Boolean;
    begin
    Application.Initialize;
    Application.MainFormOnTaskbar := True;
    Application.CreateForm(TListStatSchnittForm, ListStatSchnittForm);
    foundHandle := false;
    hMutex := CreateMutex(NIL, True, MutexName);
    if (hMutex = 0) OR (GetLastError = ERROR_ALREADY_EXISTS) then
    begin
      CloseHandle(hMutex);
      begin
        NextHandle := FindWindow('TListStatSchnittForm', nil);
        while (NextHandle > 0) and (foundHandle = false) do
        begin
          GetWindowText(NextHandle, NextTitle, 255);
          if (Pos(ListStatSchnittForm.Caption, StrPas(NextTitle)) <> 0)
            and (NextHandle <> application.Handle)
            and (NextHandle <> ListStatSchnittForm.Handle) then
          begin
            foundedHandle := NextHandle;
            foundHandle := true;
          end
          else
            NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
        end;
      end;
      if foundHandle then
      begin
        BringWindowToTop(foundedHandle);
        //ShowWindow(foundedHandle, SW_SHOW);
        halt;
      end
    end;
  Application.Run;
end.
  Mit Zitat antworten Zitat