KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Service generates error when checked with HM

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    KS-Soft Forum Index -> HostMonitor
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri Apr 04, 2003 3:13 pm    Post subject: Reply with quote

Alex, we have a couple of custom services that upon being checked by HM return an error into the Eventlog of the following sort:

Event Type: Error
Event Source: Service Control Manager
Event Category: None
Event ID: 7016
Date: 4/4/2003
Time: 11:43:31 AM
User: N/A
Computer: CHAIN3
Description:
The TPS: Chain Man service has reported an invalid current state 12febc.


My programmer wants to know what kind of API call is made to do something like that.

Below is the source for the test he did:


// QueryService.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
printf("Starting Service Queryn");

SC_HANDLE hSCM = OpenSCManager(
"CHAIN2", //"dsc1009x4v921",
SERVICES_ACTIVE_DATABASE,
SC_MANAGER_CONNECT);

if(NULL == hSCM)
{
printf("Failed calling OpenSCManager %dn", GetLastError());
}

SC_HANDLE hService = OpenService(
hSCM, // SCM database
"GARBAGEMAN", // service name
SERVICE_ALL_ACCESS);

if(NULL == hService)
{
printf("Failed calling OpenService %dn", GetLastError());
}

SERVICE_STATUS status;
QueryServiceStatus(hService, &status);

printf(" Current State: %dn", status.dwCurrentState);
printf(" Exit Code: %dn", status.dwWin32ExitCode);
printf(" Service Specific Exit Code: %dn", status.dwServiceSpecificExitCode);
printf(" Check Point: %dn", status.dwCheckPoint);
printf(" Wait Hint: %dn", status.dwWaitHint);

printf("Service Query Completen");

return 0;
}
Back to top
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Fri Apr 04, 2003 4:00 pm    Post subject: Reply with quote

HostMonitor sends SERVICE_CONTROL_INTERROGATE command to the service.
API functions used by HM:
- OpenSCManager
- OpenService
- ControlService(HandleServ, SERVICE_CONTROL_INTERROGATE, lpServiceStatus)

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    KS-Soft Forum Index -> HostMonitor All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index