Domanda

Come posso rilevare se la mia domanda è in esecuzione con l'IDE "Delphi 2007 .Net", c'è qualcosa come DebugHook?

Ciao.

È stato utile?

Soluzione

rispondere alla mia domanda.

uses System.Diagnostics; 

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

funziona bene per me.

Ciao.

Altri suggerimenti

L'IsDebuggerPresent () chiamata WinAPI.

Qualcosa di simile:

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

potrebbe soddisfare.

L'unità JEDI JclDebug.pas contiene quanto segue:

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;

Ho trovato questa risposta più generale, da Embarcadero

Con la chiamata IsDebuggerPresent() WinAPI. Esempio in C ++:

if (IsDebuggerPresent())
    Label1->Caption = "debug";
else
    Label1->Caption = "no debug";
function IsDebugMode():Boolean;
begin
  Result:=False;
 {$IFDEF DEBUG}
  Result:=True;
 {$ENDIF}
end;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top