Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4085774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:37:40+00:00 2026-05-20T18:37:40+00:00

What is the proper way to detect if the Lazarus IDE is installed in

  • 0

What is the proper way to detect if the Lazarus IDE is installed in a system programmatically using Delphi?

For example to detect if Delphi 7 is installed I can check this key HKLM\Software\Borland\Delphi\7.0.

I search for a similar key for Lazarus in the Windows registry but I don’t found anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:37:41+00:00Added an answer on May 20, 2026 at 6:37 pm

    Lazarus store a file called environmentoptions.xml by default in the <user name>\Local Settings\Application Data\lazarus folder (in some scenarios this file can be located in other folder). This file contains all the info necessary to get the Lazarus IDE location as well the FPC (Free Pascal compiler) used by the IDE.

    the environmentoptions.xml file look like this

    <?xml version="1.0"?>
    <CONFIG>
      <EnvironmentOptions>
        <Version Value="106"/>
        <LazarusDirectory Value="C:\lazarus\">
          <History Count="1">
            <Item1 Value="C:\lazarus\"/>
          </History>
        </LazarusDirectory>
        <CompilerFilename Value="C:\lazarus\fpc\2.2.4\bin\i386-win32\fpc.exe">
          <History Count="3">
            <Item1 Value="C:\fpc\2.2.4\bin\i386-win32\fpc.exe"/>
            <Item2 Value="C:\lazarus\fpc\2.2.4\bin\i386-win32\fpc.exe"/>
            <Item3 Value="C:\lazarus\fpc\2.4.2\bin\i386-win32\fpc.exe"/>
          </History>
        </CompilerFilename>
        <FPCSourceDirectory Value="c:\lazarus\fpc\2.2.4\source\">
          <History Count="1">
            <Item1 Value="c:\lazarus\fpc\2.2.4\source\"/>
          </History>
        </FPCSourceDirectory>
        <MakeFilename Value="C:\lazarus\fpc\2.2.4\bin\i386-win32\make.exe">
          <History Count="2">
            <Item1 Value="C:\fpc\2.2.4\bin\i386-win32\make.exe"/>
            <Item2 Value="C:\lazarus\fpc\2.2.4\bin\i386-win32\make.exe"/>
          </History>
        </MakeFilename>
        <TestBuildDirectory Value="C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\">
          <History Count="3">
            <Item1 Value="C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\"/>
            <Item2 Value="C:\temp\"/>
            <Item3 Value="C:\windows\temp\"/>
          </History>
        </TestBuildDirectory>
        <BackupProjectFiles AdditionalExtension="bak" MaxCounter="9"/>
        <BackupOtherFiles AdditionalExtension="bak" MaxCounter="9"/>
        <Debugger Class="TGDBMIDebugger" EventLogLineLimit="100"/>
        <DebuggerFilename Value="c:\lazarus\mingw\bin\gdb.exe">
          <History Count="4">
            <Item1 Value="c:\lazarus\mingw\bin\gdb.exe"/>
            <Item2 Value="/usr/bin/gdb"/>
            <Item3 Value="/usr/local/bin/gdb"/>
            <Item4 Value="/opt/fpc/gdb"/>
          </History>
        </DebuggerFilename>
        <Recent>
          <OpenFiles Max="10" Count="10">
          </OpenFiles>
          <ProjectFiles Max="5" Count="5">
          </ProjectFiles>
          <PackageFiles Max="10" Count="1">
            <Item1 Value="C:\Librerias\Indy10\Lib\indylaz.lpk"/>
          </PackageFiles>
        </Recent>
        <ExternalTools Count="0"/>
        <CharcaseFileAction Value="Ask"/>
        <CompilerMessagesFilename Value=""/>
      </EnvironmentOptions>
      <ObjectInspectorOptions ShowHints="False" InfoBoxHeight="50">
        <Version Value="3"/>
        <ComponentTree>
          <Height Value="97"/>
        </ComponentTree>
      </ObjectInspectorOptions>
    </CONFIG>
    

    so the steps necessaries to determine if the Lazarus IDE is installed in a Windows system are

    1. Determine the location of the <user name>\Local Settings\Application Data\lazarus using the SHGetSpecialFolderLocation function with the CSIDL_LOCAL_APPDATA value.

    2. Parse the file environmentoptions.xml to locate the LazarusDirectory Key under the EnvironmentOptions root.

    3. Now with the location of the Lazarus IDE you can check the existence of the lazarus.exe file in that folder.

    check this sample application which summarize all steps in this answer.

    {$APPTYPE CONSOLE}
    
    uses
      ShlObj,
      ComObj,
      ActiveX,
      Classes,
      Windows,
      Variants,
      SysUtils;
    
    function GetLocalAppDataFolder : string;
    const
      CSIDL_LOCAL_APPDATA        = $001C;
    var
      ppMalloc   : IMalloc;
      ppidl      : PItemIdList;
    begin
      ppidl := nil;
      try
        if SHGetMalloc(ppMalloc) = S_OK then
        begin
          SHGetSpecialFolderLocation(0, CSIDL_LOCAL_APPDATA, ppidl);
          SetLength(Result, MAX_PATH);
          if not SHGetPathFromIDList(ppidl, PChar(Result)) then
            RaiseLastOSError;
          SetLength(Result, lStrLen(PChar(Result)));
        end;
      finally
       if ppidl <> nil then
             ppMalloc.free(ppidl);
      end;
    end;
    
    
    function GetLazarusLocalFolder : string;
    begin
     Result:=Format('%slazarus',[IncludeTrailingPathDelimiter(GetLocalAppDataFolder)]);
     if not DirectoryExists(Result) then
     Result:='';
    end;
    
    
    function FileToString(const FileName: TFileName): AnsiString;
    var
       Stream : TFileStream;
    begin
      Stream:=TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
      try
          try
            SetLength(Result, Stream.Size);
            Stream.Read(Pointer(Result)^, Stream.Size);
          except
            Result:='';
          end;
      finally
         Stream.Free;
      end;
    end;
    
    function GetLazarusFolder : string;
    var
       LocalFolder : TFileName;
       FileName    : TFileName;
       XmlDoc      : OleVariant;
       Node        : OleVariant;
    begin
      Result:='';
      LocalFolder:=GetLazarusLocalFolder;
      if LocalFolder<>'' then
      begin
       FileName:=IncludeTrailingPathDelimiter(LocalFolder)+'environmentoptions.xml';
       if FileExists(FileName) then
       begin
         XmlDoc       := CreateOleObject('Msxml2.DOMDocument.6.0');
         try
           XmlDoc.Async := False;
           XmlDoc.LoadXML(FileToString(FileName));
           XmlDoc.SetProperty('SelectionLanguage','XPath');
    
            if (XmlDoc.parseError.errorCode <> 0) then
             raise Exception.CreateFmt('Error in Xml Data %s',[XmlDoc.parseError]);
    
           Node  :=XmlDoc.selectSingleNode('//CONFIG/EnvironmentOptions/LazarusDirectory/@Value');
           if not VarIsClear(Node) then
           Result:=Node.text;
         finally
           XmlDoc:=Unassigned;
         end;
       end;
      end;
    end;
    
    
    function IsLazarusInstalled : Boolean;
    begin
      Result:=FileExists(IncludeTrailingPathDelimiter(GetLazarusFolder)+'lazarus.exe');
    end;
    
    begin
     try
        CoInitialize(nil);
        try
          Writeln('Lazarus config Folder  '+GetLazarusLocalFolder);
          Writeln('Lazarus Install folder '+GetLazarusFolder);
          Writeln('Is Lazarus Installed   '+BoolToStr(IsLazarusInstalled,True));
          Readln;
        finally
          CoUninitialize;
        end;
     except
        on E:Exception do
        begin
            Writeln(E.Classname, ':', E.Message);
            Readln;
        end;
      end;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this the proper way to detect which device a user is running? NSString
What is a better (proper) way to code this according to MVC? Here's the
What's the proper way to encode untrusted data for HTML attribute context? For example:
Is this the proper way to assign a border to a cell for the
Is there any proper way to detect the environment (development or production) in the
What is the proper way to minimize a WinForms app to the system tray?
Does the system detect a difference between the keyboard done key and the keyboard
I was looking a proper way to implment a ScaleAnimation. My purpose is to
What's the proper way to add a literal text value from a field to
Is there a proper way, equation or technique in general to say, My web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.