[英]Detect if my application is running under the IDE “Delphi 2007 .Net”
How can I detect if my application is running under the IDE "Delphi 2007 .Net", there is something like DebugHook? 如何检测我的应用程序是否在IDE“Delphi 2007 .Net”下运行,有类似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: JEDI JclDebug.pas单元包含以下内容:
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 我从embarcadero找到了这个更一般的答案
Use the IsDebuggerPresent()
WinAPI call. 使用
IsDebuggerPresent()
WinAPI调用。 Example in C++: C ++中的示例:
if (IsDebuggerPresent())
Label1->Caption = "debug";
else
Label1->Caption = "no debug";
function IsDebugMode():Boolean;
begin
Result:=False;
{$IFDEF DEBUG}
Result:=True;
{$ENDIF}
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.