Question: I've heard that some custom component authors use an RTL routine that checks to see if Delphi is running in order to set up shareware restrictions. Does anyone know what this routine is? Checking obvious names like "DelphiRunning" or "IsDelphiRunning" doesn't turn up anything useful.

Answer: 
You can use DebugHook <> 0 from your component code. DebugHook is a global variable (IIRC, it's in the Systems unit) that's set by the Delphi/RAD Studio IDE, and couldn't be set from anywhere else.

There are other techniques (FindWindow() for TAppBuilder, for instance), but DebugHook takes all of the work out of it.
This is a code snippet from [www.delphitricks.com/source-code/misc/check\_if\_delphi\_is\_running.html](http://www.delphitricks.com/source-code/misc/check_if_delphi_is_running.html).

```
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;

```