SaLz
asked on
Create Service function
hi, I need help creating a service, so the app will start as a service when windows loads.
needs to be a function or procedure, something like CreateService('App Name','Discription','C:\ap p.exe','Au tomatic');
Code Examples.
thxs
Sal.
needs to be a function or procedure, something like CreateService('App Name','Discription','C:\ap
Code Examples.
thxs
Sal.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe it doesn't help, no idea. But in these Demos there's one little service demo which doesn't use Delphi's service stuff, but pure win32 APIs only. It installs and uninstalls itself simply by getting started as a normal application:
http://madshi.net/MCHDemos.zip
Look in "system wide\HookProcessTerminatio n\InjectSe rvice.dpr" .
http://madshi.net/MCHDemos.zip
Look in "system wide\HookProcessTerminatio
If the executable c:\app.exe is itself a service, created in Delphi, you can install it by executing
c:\app.exe /install
c:\app.exe /install
ASKER
ya thats the thing, 2 programs, 1 service, 1 app, anyway of having just 1 app with a service inside?
procedure TForm1.Form1Create(Sender: TObject);
begin
if ParamStr(1) = '/install' then
//install service
else if ParamStr(1) = '/uninstall' then
//uninstall service
end;
any code I can use to do this?
procedure TForm1.Form1Create(Sender:
begin
if ParamStr(1) = '/install' then
//install service
else if ParamStr(1) = '/uninstall' then
//uninstall service
end;
any code I can use to do this?
Do you have a TService component, added to your application ?
ASKER
I can add it, but how can I use it along these methods as above.
procedure TForm1.Form1Create(Sender: TObject);
begin
if ParamStr(1) = '/install' then
CreateService('App Name','Discription','C:\ap p.exe','Au tomatic');
else if ParamStr(1) = '/uninstall' then
RemoveService('App Name');
end;
how could I make a function like that 2 be called from my app to the TService unit?
procedure TForm1.Form1Create(Sender:
begin
if ParamStr(1) = '/install' then
CreateService('App Name','Discription','C:\ap
else if ParamStr(1) = '/uninstall' then
RemoveService('App Name');
end;
how could I make a function like that 2 be called from my app to the TService unit?
If you want a part of your application to act as windows service, you MUST use the TService component, it has built-in methods for communication with SCM ( Service Control Manager ), which is manipulating the services. All the logic, which must be done by the service you must put inside the TService comonent. Then you should use methods from the unit WinSvc to register your service. Tell me if you need any help doing this.
ASKER
u know how to get the service handle in the service?
like in a form its application.handle & form1.handle, but how do I get the handle when its in a service?
like in a form its application.handle & form1.handle, but how do I get the handle when its in a service?
try
service1.getservicecontrol ler
service1.getservicecontrol
ASKER