I'd like to suggest another way to do that, which may be helpful in some cases.
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"