简体   繁体   English

如何在 C++ 中获取有关服务的启动类型的信息?

[英]How do I get information about the Startup Type of a service in c++?

I'm looking for a way to get the Startup type of a service using c++.我正在寻找一种使用 C++ 获取服务的启动类型的方法。 I am able to get the SERVICE_STATUS data from a ControlService() call, but the data does not include the startup type.我能够从 ControlService() 调用中获取 SERVICE_STATUS 数据,但该数据不包括启动类型。 I'm aware there is a way to get the Startup Type using windows power shell, maybe I should make a c++ method that makes that power shell call?我知道有一种方法可以使用 windows power shell 获取启动类型,也许我应该制作一个 c++ 方法来调用 power shell? Is that the best way to do it?这是最好的方法吗?

You need to open the service with OpenService() requesting SERVICE_QUERY_CONFIG access, and then you can use QueryServiceConfig() .您需要使用请求SERVICE_QUERY_CONFIG访问权限的OpenService()打开服务,然后您可以使用QueryServiceConfig() dwStartType is one of the available fields of the returned QUERY_SERVICE_CONFIG structure data. dwStartType是返回的QUERY_SERVICE_CONFIG结构数据的可用字段之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM