Mega Code Archive

 
Categories / Delphi / Ide Indy
 

Is my app running in delphi

Title: Is my app running in delphi ? Question: Sometime, you need to know if your application is running inside the Delphi IDE, for exemple to remove the StayOnTop attribute (with it, it is tricky to debug and view source code). Answer: Here is a simple function that return True if your program is running inside a debugger (like the Delphi IDE). It use the 'IsDebuggerPresent' API, which is not linked in Delphi 3 from Kernel 32. -- Updated 16/01/2001 : if u r running in NT, call the proc in dll, else use another method. 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; Works fine with D3 on WinNT.