Event logging service

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
How can I know programmatically if the event logging service exists in the
XPE target ?
I 'm tried to write in a log file if the RegisterEventSource fails, but in
my XPE target where there is not Event Logging Service, the
RegisterEventSource function seems to be executed correctly, Is there another
way ?

Thanks in advance
 
You can use service control manager infrastruture to query service:

SC_HANDLE schSCManager;
SC_HANDLE evntService;

schSCManager = OpenSCManager(
NULL, // local machine
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); //needed rights

if (NULL!= schSCManager )

schService = OpenService(
schSCManager , // SCM
"Eventlog", // Event Log service name
SERVICE_ALL_ACCESS ); //needed rights


if (NULL!=schService)
{
//service exists and working

}
else
{
//error processing
}

Note, that you may need add code for additional error processing.
 
Thank you

Stas Pavlov (eMVP) said:
You can use service control manager infrastruture to query service:

SC_HANDLE schSCManager;
SC_HANDLE evntService;

schSCManager = OpenSCManager(
NULL, // local machine
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); //needed rights

if (NULL!= schSCManager )

schService = OpenService(
schSCManager , // SCM
"Eventlog", // Event Log service name
SERVICE_ALL_ACCESS ); //needed rights


if (NULL!=schService)
{
//service exists and working

}
else
{
//error processing
}

Note, that you may need add code for additional error processing.
 
Back
Top