Event logging service

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
 
S

Stas Pavlov \(eMVP\)

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top