Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More than one service using same application

Status
Not open for further replies.

ciunada

Programmer
May 11, 2010
2
IT
Hello,

I need to create a service application which can be started X times as a service.
I used the following code:
procedure TMyService.ServiceBeforeInstall(Sender: TService);
begin
if ParamStr(1)='-install' then IHotel := ParamStr(2) else IHotel :=
ParamStr(1);
IHotel := TRIM(AnsiReplaceText(Copy(IHotel,2), ' ', ''));
if Length(IHotel) = 0 then
begin
Showmessage('Hotel name not specified.' + #13 + 'Service can not be
installed');
Abort;
end;

DisplayName := 'Opera IFC8 AliveCheck for ' + IHotel;
Name := 'MyServiceAliveCheckfor' + IHotel;
end;

Problem is that service freeze on startup when I change service name with last line of the above procedure. If I comment last line service works perfectly but then I can install only one service as the second one will have same name then the first one.

Is there anyone who can help please?

Regards
Elena
 
Hi Elena,

welcom to these forums!
please post code between code tags (look here for more information)

I tested your code under Delphi2006 and it works perfectly.
Try to debug with debug DCU's activated to see what's going wrong.
On another note, I would however never do it like this.
I would use a configuration file(xml, ini, ...) and spawn threads accordingly.

Cheers,
/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks whosrdaddy for your reply.

Yes, you are right, the code itself works because the service is installed but if you try to start one of the services installed it will freeze.
I believe it is due to the NAME value I'm changing here.
Am I wrong?

Thanks a lot
Elena
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top