Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > finding the status of the service in windows

Reply
Thread Tools

finding the status of the service in windows

 
 
suresh_rtp suresh_rtp is offline
Junior Member
Join Date: Feb 2009
Posts: 4
 
      05-26-2009
hi,
this is the cod that i was written for getting the service status.i have some problem in this code.i am not able to getting the staus of the service.anybody another code help me.


DWORD ServiceGetStatus(char *sService)
{
SC_HANDLE schm;
SC_HANDLE schs;
LPSERVICE_STATUS TServiceStatus = NULL;
DWORD dwStat = -1;
// connect to the service control manager
schm = OpenSCManager(NULL,NULL,SC_MANAGER_CONNECT);
if(schm > 0)
{
schs = OpenService(schm,sService,SERVICE_QUERY_STATUS);

if(schs > 0)
{
if(QueryServiceStatus(schs,TServiceStatus))
{
dwStat = TServiceStatus->dwCurrentState;
CloseServiceHandle(schs);
CloseServiceHandle(schm);
}
std::cout<<"status is false"<<std::endl;
}
}
return dwStat;
}
int main()
{
DWORD status = 0;
const char machine[]="";
CHAR Service_Name[32];
strcpy(Service_Name,"Sundar_Service");
status = ServiceGetStatus(Service_Name);
if(status == 1)
std::cout<<"service stopped"<<std::endl;
if(status == 4)
std::cout<<"service is running"<<std::endl;
return 0;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I use more than one status condition name in imaplib.status() harryos Python 0 10-13-2010 01:37 PM
Recommend a free 'Status Monitor' or 'Dashboard' to report overnight tasks status? Shug Java 13 12-15-2006 06:22 PM
Recommend a free 'Status Monitor' or 'Dashboard' to report overnight tasks status? Shug C++ 13 12-15-2006 06:22 PM
finding remote computer desktop lock status in windows 2003 server network ? satlal Computer Security 3 09-06-2005 01:23 PM
POST problem - IIS sc-win32-status:64; sc-status:400 saha ASP .Net 0 07-14-2005 07:10 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57