Einzelnen Beitrag anzeigen

Alaitoc

Registriert seit: 24. Okt 2008
263 Beiträge
 
Delphi 7 Enterprise
 
#6

Re: MSXML-Parser, aber welcher?

  Alt 19. Nov 2009, 11:20
Unter Delphi 2k9 kann man die Typbibiliothek über "Komponente\Komponente importieren" hinzufügen.
Einfach im Assistenten "Typbibliothek importieren" auswählen und dann nach MSXML suchen und die
gewünschte Version auswählen.

Damit sollte man zumindest mehr Möglichkeiten haben als mit der TXMLKomponente.

Wichtig: Der Anwender muss natürlich die dementsprechende Version auf dem Rechner haben.

Das kann man z.b. mit dieser Funktion feststellen, die ich irgendwo hier im Forum gefunden habe...

Leider vergessen wo genau her ^_° und bin mir nicht sicher ob man Änderungen für Delphi 2k9 dran vornehmen muss...

Delphi-Quellcode:

unit MSXMLCheck;

interface

uses SysUtils, Registry, Windows, Dialogs, MSXML6_TLB;

function CheckMSXML60:Boolean;
function CheckMSXML40:Boolean;
function CheckMSXML30:Boolean;
function CheckMSXML26:Boolean;

implementation

//**************************************************************************************
// Überprüfen der angegebenen MSXML Version durch die Registry
//**************************************************************************************

function ExpandEnvStr(const sInput: string): string;
const
  MAXSIZE = 32768;
begin
  SetLength(Result,MAXSIZE);
  SetLength(Result,
            ExpandEnvironmentStrings //The ExpandEnvironmentStrings function expands environment-variable strings and replaces them with their defined values.
              (pchar(sInput), // LPCTSTR lpSrc = pointer to string with environment variables
              @Result[1], // LPTSTR lpDst = pointer to string with expanded environment variables
              length(Result))); // DWORD nSize = maximum characters in expanded string
end;

function DoesMSXMLExist(CLASS_DOMDocument:TGUID): boolean;
var
  reg : TRegistry;
  s : string;
begin
  Result := false;

  reg := TRegistry.Create(KEY_READ);
  if(reg <> nil) then
    with reg do
    begin
      try
        RootKey := HKEY_CLASSES_ROOT;
        if(OpenKey('CLSID\' + GuidToString(CLASS_DOMDocument) + '\InProcServer32',false)) then
        try
          s := ReadString('');
          Result := fileexists(ExpandEnvStr(s));
        finally
          CloseKey;
        end;
      finally
        Free;
      end;
    end;
end;

//**************************************************************************************
// Überprüfen (MSXML 6.0)
//**************************************************************************************

function CheckMSXML60:Boolean;
begin
  result:=DoesMSXMLExist(CLASS_DOMDocument60);
end;

//**************************************************************************************
// Überprüfen (MSXML 4.0)
//**************************************************************************************

function CheckMSXML40:Boolean;
begin
  result:=DoesMSXMLExist(CLASS_DOMDocument40);
end;

//**************************************************************************************
// Überprüfen (MSXML 3.0)
//**************************************************************************************

function CheckMSXML30:Boolean;
begin
  result:=DoesMSXMLExist(CLASS_DOMDocument30);
end;

//**************************************************************************************
// Überprüfen (MSXML 2.6)
//**************************************************************************************

function CheckMSXML26:Boolean;
begin
  result:=DoesMSXMLExist(CLASS_DOMDocument26);
end;

end.
  Mit Zitat antworten Zitat