怎样知道我的程序是否运行在DELPHI?

类别:Delphi 点击:0 评论:0 推荐:
function IsAppRunningInDelphi : boolean;
var
  hKernelDll : THANDLE;
  proc_IsDebuggerPresent : TProcIsDebuggerPresent;
  useFindWindow : boolean;
  proc : FARPROC;
begin
  useFindWindow := true;
  if (Win32Platform = VER_PLATFORM_WIN32_NT) then
  begin
    // WinNt
    try
      hKernelDll := GetModuleHandle(kernel32);
      if (hKernelDll = -1) then
        hKernelDll := LoadLibrary(kernel32);
      if (hKernelDll <> -1) then
      begin
        proc := GetProcAddress(hKernelDll, 'IsDebuggerPresent');
        if (proc <> nil) then
        begin
          proc_IsDebuggerPresent := proc;
          result := proc_IsDebuggerPresent;
          useFindWindow := false;
        end;
      end;
    except
    end;
  end;
  if (UseFindWindow) then
  begin
    if FindWindow('TAppBuilder', Nil) <> 0 Then
      result := true
    else
      result := false;
  end;
end;

本文地址:http://com.8s8s.com/it/it5861.htm