Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Feb : issues with service application

www.cryer.info
Managed Newsgroup Archive

issues with service application

Subject:issues with service application
Posted by:"Eugene V. Goldberg" (ego..@mts-nn.ru)
Date:Wed, 27 Feb 2008 07:48:01

Hi there,

I have a D5 service app..

1. I cant stop it properly from SCM...SCM says
    Can not stop the XXX on Local Computer.
    The service did not return any error. This could be internal Windows
error  or an internal service error.
    If the problem persist etc...

    Execute method looks like this

  CoInitialize(nil);
  try
    while not Terminated do
    begin
       //do some stuff
     end;
    end
  finally
    CoUnInitialize
  end

    Why it cant stop it?

2. I am using TEventLogger class to post messages to EventLog.

   EventLogger := TEventLogger.Create('My Service Name');
   EventLogger.LogMessage('My Message', EVENTLOG_INFORMATION_TYPE))

   When i call this directly from service class, it works just fine.
    However i have an object which i use i service code, and i assign an
event handler
    for it which logs the  messages from this object using the same code as
i do in service class.
    And in this case, it appears under different "Source" in event viewer
and have an error mark,
    not information. The source being used is my service class name, not the
display name.

procedure TBrokerService.ServiceCreate(Sender: TObject);
......
  FUnPackager := TCitUnPackager.Create;
  FUnPackager.OnLogEvent := DoUnPackagerLog;

procedure TBrokerService.LogEvent(const Msg: String);
begin
  FLogger.LogMessage(Msg, EVENTLOG_INFORMATION_TYPE);
end;

TOnLogEvent = procedure (Msg: String) of object;
TCitUnPackager = class
    ....
property OnLogEvent: TOnLogEvent read FOnLogEvent write FOnLogEvent;

Any advice is welcome.

Thanx,
Eugene.


procedure TBrokerService.DoUnPackagerLog(LogMsg: String);
begin
  LogEvent(LogMsg)
end;

Replies:

www.cryer.info
Managed Newsgroup Archive