Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if my application is running under the IDE "Delphi 2007 .Net"

How can I detect if my application is running under the IDE "Delphi 2007 .Net", there is something like DebugHook?

Bye.

like image 334
RRUZ Avatar asked Jun 29 '09 10:06

RRUZ


4 Answers

Answer my own question.

uses System.Diagnostics; 

function IDEDelphiNetRunning:Boolean; 
Begin 
Result:=Debugger.IsAttached; 
End; 

works fine for me.

Bye.

like image 191
RRUZ Avatar answered Oct 17 '22 08:10

RRUZ


The IsDebuggerPresent() WinAPI call.

like image 20
Icebob Avatar answered Oct 17 '22 08:10

Icebob


Something like:

Function IDEIsRunning : boolean;
begin
  result := DebugHook <> 0;
end;

Might Suit.

like image 31
Alister Avatar answered Oct 17 '22 10:10

Alister


The JEDI JclDebug.pas unit contains the following:

function IsDebuggerAttached: Boolean;
var
  IsDebuggerPresent: function: Boolean; stdcall;
  KernelHandle: THandle;
  P: Pointer;
begin
  KernelHandle := GetModuleHandle(kernel32);
  @IsDebuggerPresent := GetProcAddress(KernelHandle, 'IsDebuggerPresent');
  if @IsDebuggerPresent <> nil then
  begin
    // Win98+ / NT4+
    Result := IsDebuggerPresent
  end
  else
  begin
    // Win9x uses thunk pointer outside the module when under a debugger
    P := GetProcAddress(KernelHandle, 'GetProcAddress');
    Result := DWORD(P) < KernelHandle;
  end;
end;
like image 38
Kris De Decker Avatar answered Oct 17 '22 08:10

Kris De Decker