Querying Service Control Manager (C#)

  • Thread starter Thread starter Mrinal Kamboj
  • Start date Start date
M

Mrinal Kamboj

Hi ,

Any idea regarding which class to use for querying the SCM and get
various details , i actually want to build up a tool for accomplishing
various taska of mine rather than doing them manually .

Just for information "System.ServiceProcess.Servicecontroller" class is
not what i am searching for , as that is something that can be mapped to
each individual service in SCM to carry out some tasks , but i first
want to query the console to get various details .

I think it must be some WMI class , but not very sure .

any pointers will be good .

thanks ,

Mrinal
 
Mrinal,

You have two options here. The first is like you said, WMI (using the
Win32_Service class). The second is to make the calls to the various
service control functions through the P/Invoke layer.

What kind of information are you trying to get?

Hope this helps.
 
Hi Mrinal,

Thanks for your post.

I am not sure what exact function you want to get. The Win32 Services API
is documented in the link below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
e/service_functions.asp

Which function you want to get in .Net? "Nicholas Paldino [.NET/C# MVP]"
has provided the correct WMI class: Win32_Service. If you want to use the
second option: using Win32 API, I want to add some more information. In
Net, some of the Win32 Services API functions is implemented in .Net, we
may get the Win32 API to .Net class map in the article below:
"Microsoft Win32 to Microsoft .NET Framework API Map"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/win32map.asp

You may get the services function map in "Service Functions" section. For
other services API that is not documented in this link, I think we have to
P/invoke to use it.

Hope this helps.
==================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Mrinal,

Does our replies make sense to you? If you still have any concern, please
feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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

Back
Top