Habe vor einiger Zeit eine Delphi VCL Formular Anwendung geschrieben und auch über die Jahre gepflegt. Läuft prima, auch an Win7 angepasst.
Nun ist der Wunsch aufgekommen, diese EXE als Windows Dienst laufen zu lassen. Nichts leichter als das: Mit Delphi Wizard einen Dienst erstellt und das alte Hauptfenster unter
Application.CreateForm(TService,Service);
Application.CreateForm(TForm1,Form1);
eingebaut. Läuft auch alles ohne Probleme. Aber jetzt ist weiteres begehren aufgetaucht: Die beiden *.dpr Dateien unterscheiden sich minimal. Gibt es eine Möglichkeit zu erkennen, ob die EXE als Dienst oder als Formular Anwendung gestartet wird? Dann bräuchte ich keine 2 EXE erstellen und wenn Formulare gewünscht wären (da ein Dienst unter Win7 mit Desktop 0 ja nicht mit den user Desktop spricht) könnte dieser einfach so gestartet werden.
Nun ist der Wunsch aufgekommen, diese EXE als Windows Dienst laufen zu lassen. Nichts leichter als das: Mit Delphi Wizard einen Dienst erstellt und das alte Hauptfenster unter
Application.CreateForm(TService,Service);
Application.CreateForm(TForm1,Form1);
eingebaut. Läuft auch alles ohne Probleme. Aber jetzt ist weiteres begehren aufgetaucht: Die beiden *.dpr Dateien unterscheiden sich minimal. Gibt es eine Möglichkeit zu erkennen, ob die EXE als Dienst oder als Formular Anwendung gestartet wird? Dann bräuchte ich keine 2 EXE erstellen und wenn Formulare gewünscht wären (da ein Dienst unter Win7 mit Desktop 0 ja nicht mit den user Desktop spricht) könnte dieser einfach so gestartet werden.
Comment