我用EnumServicesStatus获得系统所有服务信息,然后将ENUM_SERVICE_STATUS中的lpDisplayName显示到一棵树中。程序运行后发现显示出来的列表要比我在控制面板的服务中看到的要多。请问为什么会多显示很多服务呢?谢谢。

解决方案 »

  1.   

    参考一下参数信息dwServiceType 
    [in] Type of services to enumerate. This parameter can be one or more of the following values. Value Meaning 
    SERVICE_DRIVER Enumerates services of type SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER. 
    SERVICE_WIN32 Enumerates services of type SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS. dwServiceState 
    [in] State of the services to be enumerated. This parameter can be one of the following values. Value Meaning 
    SERVICE_ACTIVE Enumerates services that are in the following states: SERVICE_START_PENDING, SERVICE_STOP_PENDING, SERVICE_RUNNING, SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, and SERVICE_PAUSED. 
    SERVICE_INACTIVE Enumerates services that are in the SERVICE_STOPPED state. 
    SERVICE_STATE_ALL Combines the following states: SERVICE_ACTIVE and SERVICE_INACTIVE. 
      

  2.   

    我已经找到问题了,我多加了个SERVICE_DRIVER参数:)谢谢。