怎样知道我的程序是否运行在DELPHI?
2006-02-04 13:34:42 来源:WEB开发网核心提示:function IsApPRunningInDelphi : boolean; var hKernelDll : THANDLE; proc_IsDebuggerPresent : TProcIsDebuggerPresent; useFindWindow : boolean; proc : FARPROC; beg
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;
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;
更多精彩
赞助商链接