Search code examples
xmldelphimsxml

How determine if MSXML6 is installed in a system using Delphi?


I have an application which depends of the MSXML6, in most of the machines when the application is deployed this package is already installed, but in a few cases the MSXML6 is not installed, The question is how I can check if the MSXML 6 is already installed?


Solution

  • you can check if the CLSID exist in the registry using the CLSIDFromProgID function, for MSXML the CLSID is Msxml2.DOMDocument.6.0

    Check this sample app

    uses
      ActiveX,
      SysUtils;
    
    {
            Msxml2.DOMDocument.2.6
            Msxml2.DOMDocument.3.0
            Msxml2.DOMDocument.4.0
            Msxml2.DOMDocument.5.0
            Msxml2.DOMDocument.6.0
    }
    var
      clsid: TCLSID;
    begin
      try
        if Succeeded(CLSIDFromProgID('Msxml2.DOMDocument.6.0', clsid)) then
         Writeln('MSXML 6.0 Installed')
        else
         Writeln('MSXML 6.0 Not Installed');
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
      Readln;
    end.