views:

321

answers:

3

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

Bye.

+3  A: 

The IsDebuggerPresent() WinAPI call.

Icebob
This isn't really an answer to the question though, as running the application under Delphi and running it under any other debugger can not be distinguished this way. Maybe that's not important for the OP, but the question should have been worded differently then. Also there is Debugger.IsAttached in System.Diagnostics, no need to call the Windows API.
mghie
+1  A: 

Something like:

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

Might Suit.

Alister
Alister, DebugHook does not exist in "Delphi 2007.Net", so look for some alternative.
RRUZ
Well, I was searching for how to do exactly the same thing as OP... but in Delphi 5. So naturally this worked perfectly for me. :) +1
Craig Young
+1  A: 

Answer my own question.

uses System.Diagnostics; 

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

works fine for me.

Bye.

RRUZ