How can I detect if my application is running under the IDE "Delphi 2007 .Net", there is something like DebugHook?
Bye.
Answer my own question.
uses System.Diagnostics;
function IDEDelphiNetRunning:Boolean;
Begin
Result:=Debugger.IsAttached;
End;
works fine for me.
Bye.
IsDebuggerPresent()WinAPI调用。
Something like:
Function IDEIsRunning : boolean;
begin
result := DebugHook <> 0;
end;
Might Suit.
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;
I found this more general answer, from embarcadero
Use the IsDebuggerPresent()
WinAPI call. Example in C++:
if (IsDebuggerPresent())
Label1->Caption = "debug";
else
Label1->Caption = "no debug";
function IsDebugMode():Boolean;
begin
Result:=False;
{$IFDEF DEBUG}
Result:=True;
{$ENDIF}
end;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.