[SOLVED] Detect if running in the IDE lazarus / 13-General ---------------------------------------------------------------------- pcurtis · 2021-05-29 05:32 How to detect if my program is running in the IDE? ---------------------------------------------------------------------- dbannon · 2021-05-29 09:44 I bet someone knows a better way but ... In the IDE, set an environment variable of you choice, if you can find it with GetEnvironmentVariable() you must be in the IDE. Davo ---------------------------------------------------------------------- pcurtis · 2021-05-29 10:35 That will be fine, just where do I set the variable? ---------------------------------------------------------------------- Martin_fr · 2021-05-29 10:39 You mean: In the IDE or "under a debugger" You can run from the IDE, but without debugger. And you can run in a debugger, but outside the IDE. ---------------------------------------------------------------------- Martin_fr · 2021-05-29 10:40 Afaik on win64, with gdb 7.3.5 environment can not be set. But please double check. With any other gdb it should work. ---------------------------------------------------------------------- pcurtis · 2021-05-29 11:26 In the IDE ---------------------------------------------------------------------- dseligo · 2021-05-30 10:31 If it is just for your testing or similar you could set some command line parameter in Run/Run Parameters (e.g. /ide). Then you just don't use this parameter when program is run outside of IDE. In Run Parameters you can set environment variables, also. ---------------------------------------------------------------------- pcurtis · 2021-05-30 11:05 Thanks. What I needed. ---------------------------------------------------------------------- Manlio · 2021-09-20 16:11 I'd like to suggest another way to do that, which may be helpful in some cases. Code: [Select]function InIDE: boolean; var fn1, fn2: string; begin   fn1 := ParamStr(0);   fn2 := ChangeFileExt(fn1, '.lpr');   result := FileExists(fn2) end; As you can see, if my program is e.g. "myprogram.exe", I look for a file named "myprogram.lpr" in the same folder. If I find it, I know that I'm running the program in my own development folder, which is usually what I want to know, as opposed to the program running in an installed folder such as "Program Files" or "Applications"