Category: Miscellaneous
Title: Check if Delphi is running
Date added: 15.03.2006
Hits: 1916
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;
function DelphiIsRunning: Boolean;
begin
Result := DebugHook <> 0;
end;