Einzelnen Beitrag anzeigen

Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#2

AW: Merkwürdiges Öffnen einzelner Projekte

  Alt 2. Jul 2010, 12:47
Ich habe folgendes durch Zufall herausgefunden. Es liegt an meiner Projektquelldatei:

Delphi-Quellcode:
program KECSystemManagement;

uses
  Windows,
  SysUtils,
  Forms,
  Dialogs,
  MSXML2_TLB,
  Registry,

  uMain in 'uMain.pas{frm_main},
  uService in 'uService.pas{frm_service},
  MpuWinNT in 'MpuWinNT.pas',
  CheckUser in 'CheckUser.pas',
  ActiveDs_TLB in 'ActiveDs_TLB.pas',
  adshlp in 'adshlp.pas',
  uLogin in 'uLogin.pas',
  uSystemEventlog in 'uSystemEventlog.pas{frm_systemeventlog},
  uPowerRemoteConsole in 'uPowerRemoteConsole.pas{frm_powerremoteconsole},
  StartOnce in 'StartOnce.pas',
  uHostAlive in 'uHostAlive.pas',
  uSystem in 'uSystem.pas{frm_system},
  uContact in 'uContact.pas{frm_contact};

{$R *.res}

function DoesXMLExist: boolean;
var
 reg : TRegistry;
 s : string;
begin
 Result := false;
 reg := TRegistry.Create(KEY_READ);
 if reg <> nil then
 begin
   with reg do
   try
     RootKey := HKEY_CLASSES_ROOT;
     if OpenKey('CLSID\' + GuidToString(CLASS_DOMDocument40)+ '\InProcServer32', false) then
     try
       s := ReadString('');
       s := StringReplace(s,'%SystemRoot%',GetEnvironmentVariable('SYSTEMROOT'),[rfReplaceAll]); // falls eine Systemvariable gesetzt ist
       Result := (s <> '') and (fileexists(s));
     finally
      CloseKey;
     end;
   finally
     Free;
   end;
 end;
end;

begin
  ReportMemoryLeaksOnShutdown := True;
  Application.Initialize;
  Application.Title := 'KECSystemManagement';
  if not DoesXMLExist then
  begin
    MessageDlg('MSXML 4.0 is required. ' + Application.Title + 'will be terminated.',mtInformation,[mbOK],0);
    Application.Terminate;
  end
  else
  begin
    Application.CreateForm(Tfrm_main, frm_main);
    Application.CreateForm(Tfrm_service, frm_service);
    Application.CreateForm(Tfrm_systemeventlog, frm_systemeventlog);
    Application.CreateForm(Tfrm_powerremoteconsole, frm_powerremoteconsole);
    Application.CreateForm(Tfrm_system, frm_system);
    Application.CreateForm(Tfrm_contact, frm_contact);
    Application.Run;
  end;
Wenn ich Application.CreateForm(Tfrm_main, frm_main); außerhalb der IF Anweisung setze, wird das Formular auch beim Start des Projektes auch gleich mitgeöffnet. Hat aber zur Folge, dass mein Programm zur Laufzeit erst das Formular erstellt und dann erst XML prüft. Das würde ich ungern machen wollen.

Gibt es noch einen anderen Weg?

Gruß, Sven
  Mit Zitat antworten Zitat