CSDN博客

img laoli

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

发表于2001/10/5 14:16:00  900人阅读

分类: delphi文档

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;
0 0

相关博文

我的热门文章

img
取 消
img