This article demonstrates how to write a service for Win9X
One of the most beneficial features on WinNT and Win2000 is the ability to run applications in the background, serving requests behind the scenes.
It is a shame that Windows95/98 does not have this same feature, obviously it is because it was not meant to be a network server of any kind. However, sometimes it is necessary to have a task running as a service on Windows95/98, so the nice people at Microsoft decided to implement what I would consider "a hack".
Write your application, in the project source do this.
Application.ShowMainForm := False; //<-- Add this !!
This will stop your main form appearing when your application is run.
Now in the registry
Make a string entry pointing to your application.
Finally, in the OnCreate of your form call
The code for InternalRegisterServiceProcess is as follows.
TServiceFunc = function (aProcessID: DWord;
aType: DWord): WordBool; stdcall;
const StartService : Boolean) : Boolean;
Result := False;
HKernel32 := LoadLibrary('Kernel32.dll');
if HKernel32 > 0 then
P := GetProcAddress(HKernel32,'RegisterServiceProcess');
if Assigned(P) then
dwProcess := GetCurrentProcessID;
dwType := 0;
case StartService of
True : dwType := 1;
False : dwType := 0;
Result := P(dwProcess, dwType);