...kontrollieren, ob Delphi gestartet ist?

Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch

Kategorie: Sonstiges

function WindowExists(AppWindowName, AppClassName: string): Boolean;
var
  
hwd: LongWord;
begin
  
hwd    := 0;
  hwd    := FindWindow(PChar(AppWindowName), PChar(AppClassName));
  Result := False;
  if not (Hwd = 0) then {window was found if not nil}
    
Result := True;
end;

function DelphiLoaded: Boolean;
begin
  
DelphiLoaded := False;
  if WindowExists('TPropertyInspector', 'Object Inspector') then
    if 
WindowExists('TMenuBuilder', 'Menu Designer') then
      if 
WindowExists('TAppBuilder', '(AnyName)') then
        if 
WindowExists('TApplication', 'Delphi') then
          if 
WindowExists('TAlignPalette', 'Align') then
            
DelphiLoaded := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if 
DelphiLoaded then
  begin
    
ShowMessage('Delphi is running');
  end;
end;

// To know if a Application is running under de Delphi IDE or
// when it's running stand-alone:
function DelphiIsRunning: Boolean;
begin
  
Result := DebugHook <> 0;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base