Home > database >  How does Delphi's TXMLDocument decide which MS XML version (3.0, 6.0 or even 4.0) to use?
How does Delphi's TXMLDocument decide which MS XML version (3.0, 6.0 or even 4.0) to use?

Time:11-17

I have a program written in Delphi 6 that uses TXMLDocument, and during runtime it uses the MS XML 3.0 parser. But this program reports a The specified module could not be found error on one computer, and Process Monitor reports that the program is trying to access MS XML 4.0 modules and registry keys. This 4.0 installation is incomplete/corrupted and that is why the access fails with The specified module could not be found.

So, the core issue is some mechanism/decision algorithm that diverts TXMLDocument from using the standard MS XML 3.0 or MS XML 6.0 versions that are on all the current Windows 10 machine, and that presses TXMLDocument to use MS XML 4.0 version. What is this decision mechanism in TXMLDocument and how to correct it?

Of course, I can find, download, and install MS XML 4.0 on the client computer, but this seems to not be the correct solution.

CodePudding user response:

There is no secret magic here. It is well known what mechanism is used. You can see the source code for yourself in Delphi's msxmldom.pas file.

When TXMLDocument uses the MSXML DOMVendor on Windows, it simply calls CoCreateInstance() in a loop to attempt to instantiate a hard coded list of different versions of MSXML's IXMLDOMDocument COM object, in decreasing order of version, until one version finally succeeds, or they all fail.

MSXML 6.0 did not exist yet when Delphi 6 was released, so it is not a version that is attempted. And you said MSXML 4.0 is broken on your customer's system. So it makes sense why MSXML 3.0 ends up being used instead.

Have a look at the following question for how to make TXMLDocument use MSXML 6.0 in such an old Delphi version:

How to create a TXML Document using MSXML 6.0 in Delphi 7?

  • Related