Check If a Windows Service is Installed or not? (C++) -
this question has answer here:
- check if services installed using c 2 answers
i have written windows service in c++, works perfectly, want add feature when try install can first check has been installed or not?
i have tried ideas on how task there not there. of quesions , tutorials c# programmers , using servicecontroller task, unable access such class in c++.
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx
the above link shows no example class in example portion , says that:
"no code example available or language may not supported."
other information: using windows 7 64 bit, visual studio 2008, language c++.
any sort of highly appreciated. thanks.
update: leave answer below, duplicate of this , marked such.
you use openservice
win32 api. returns handle service, or null
if service in question not exist (and getlasterror()
return error_service_does_not_exist
; there other error reasons well, don't forget check that). also, don't forget call closeservicehandle
in case call succeeds. .net classes mentioned use underneath well.
you can information database of installed services, in windows registry.
alternatively, can run external commands (e.g. sc.exe
or powershell
) form installer query information.
Comments
Post a Comment