Come posso rilevare se la mia applicazione è in esecuzione sotto l'IDE "Delphi 2007 .Net", c'è qualcosa come DebugHook?Rileva se la mia applicazione è in esecuzione sotto l'IDE "Delphi 2007 .Net"
Ciao.
Come posso rilevare se la mia applicazione è in esecuzione sotto l'IDE "Delphi 2007 .Net", c'è qualcosa come DebugHook?Rileva se la mia applicazione è in esecuzione sotto l'IDE "Delphi 2007 .Net"
Ciao.
Rispondi alla mia domanda.
uses System.Diagnostics;
function IDEDelphiNetRunning:Boolean;
Begin
Result:=Debugger.IsAttached;
End;
funziona bene per me.
Ciao.
La chiamata WinAPI IsDebuggerPresent().
Qualcosa di simile:
Function IDEIsRunning : boolean;
begin
result := DebugHook <> 0;
end;
potrebbe soddisfare.
Alister, DebugHook non esiste in "Delphi 2007.Net", quindi cerca qualche alternativa. – RRUZ
Beh, stavo cercando come fare esattamente la stessa cosa di OP ... ma in Delphi 5. Quindi naturalmente questo ha funzionato perfettamente per me. :) +1 –
Funziona su Delphi 7 ;-) – NetVicious
ho trovato questa risposta più generale, da embarcadero
Utilizzare la chiamata IsDebuggerPresent()
WinAPI. Esempio in C++:
if (IsDebuggerPresent())
Label1->Caption = "debug";
else
Label1->Caption = "no debug";
L'unità JEDI JclDebug.pas contiene i seguenti:
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;
La domanda è rivolta in particolare al debugger "Delphi 2007.net", non solo a un debugger. –
function IsDebugMode():Boolean;
begin
Result:=False;
{$IFDEF DEBUG}
Result:=True;
{$ENDIF}
end;
Questo non ti dice se stai usando il debugger. Ti dice semplicemente se DEBUG è stato definito in fase di compilazione. Quindi hai postato una risposta totalmente sbagliata a una domanda di 6 anni che già aveva più risposte corrette esistenti. –
Questo non è realmente una risposta alla domanda se, come esegue l'applicazione sotto Delphi e eseguirlo con qualsiasi altro debugger non può essere distinto in questo modo. Forse non è importante per l'OP, ma la domanda avrebbe dovuto essere formulata in modo diverso allora. Inoltre c'è Debugger.IsAttached in System.Diagnostics, non c'è bisogno di chiamare l'API di Windows. – mghie