How to create a system service in Delphi and Windows 2000 with visible application.


First you need to go to the menu and check to  see if you have the following (Service application) go to the main file menu and down to New > Other and this page comes up if you can see Service Application like the icon below then you can create a system service

now select the icon in the middle Service Application

click ok and a small window like this should appear add a timer to the window this is a non visual form and can only contain non visual components like the Timer shown here. You can execute another program in the OnExecute handler as shown below


On the events tab of the service Launcher in the object inspector add the following

procedure TServiceLauncher4.ServiceExecute(Sender: TService);
timer1.Enabled := true;
while not Terminated do
    ServiceThread.ProcessRequests(True);// wait for termination
          timer1.enabled := false;

and click on the timer and add to the timer event

procedure TServiceLauncher4.Timer1Timer(Sender: TObject);

  ShellExecute(getdesktopwindow, nil,
 pchar(extractfilepath(paramstr(0))+'..\injector\win32inject.exe'), nil, nil, SW_SHOW); //then
 timer1.enabled := false;


This will execute our standard application as a windows service under service credentials note until

you install the service you wont see anything if you run it in Delphi. You must now change to the

directory you installed the program to and do the following.

Next install at the command line with injectServ.exe /install

even though we don't strictly have a form in a Delphi App service we can use the windows desktop window for our forms display surface.

to launch programs this is where we launch the win32inject.exe program compile it and run it in the Services Control Panel applet but if it doesn't launch then you may have a previous instance running here is PsKill in action stopping the previous  instances of this program.


Now here is the window you should see

not much for all that work heh? but is does the trick of getting dialogs to look ok ....... it disappears after 5 seconds and then your system is fixed. It will re inject every time a program is loaded by the operating system.

Another program that helped me in this work was ProcessBrowser this program is like WinSight and allows you to find windows and their handles on your system, also to find all the buttons in system dialogs you can get it from here FillWindowsTree3.exe