How to get the status of a service programmatically (Running/Stopped)
问题 I need to get the status of Windows "print spooler" service in my C++ application. 回答1: Use QueryServiceStatus or QueryServiceStatusEx. There are plenty of examples on the web on how these are used. 回答2: The function that @shikarssj provided is working perfectly, it only requires admin rights when loading the service. Here is a version that does not ask for full permission: #include <Windows.h> int GetServiceStatus( const char* name ) { SC_HANDLE theService, scm; SERVICE_STATUS m_SERVICE