Question

Comment puis-je détecter si ma demande est en cours d'exécution sous l'IDE « Delphi 2007 .Net », il y a quelque chose comme DebugHook?

Au revoir.

Était-ce utile?

La solution

Répondez à ma propre question.

uses System.Diagnostics; 

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

fonctionne très bien pour moi.

Au revoir.

Autres conseils

Le IsDebuggerPresent () appel WinAPI.

Quelque chose comme:

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

peut emboîter le pas.

L'unité JEDI JclDebug.pas contient le texte suivant:

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;

J'ai trouvé cette réponse plus générale, de Embarcadero

Utilisez l'appel WinAPI IsDebuggerPresent(). Exemple en C ++:

if (IsDebuggerPresent())
    Label1->Caption = "debug";
else
    Label1->Caption = "no debug";
function IsDebugMode():Boolean;
begin
  Result:=False;
 {$IFDEF DEBUG}
  Result:=True;
 {$ENDIF}
end;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top