Python win32serviceutil QueryServiceStatus:返回值是什么意思?

时间:2018-02-18 12:07:19

标签: python winapi pywin32

我正在学习使用pywin32,并尝试在64位Python 3.6.4上使用win32serviceutil模块

以下代码:

import win32serviceutil as service
serviceStatus = service.QueryServiceStatus("WinDefend")
print(serviceStatus)

返回以下元组:

(16, 4, 197, 0, 0, 0, 0)

我对windows api和pywin32完全不熟悉,这6个值是什么意思?有关pywin32和win32的任何文档都没有透露任何内容。

编辑 - 我正在运行Windows 10

2 个答案:

答案 0 :(得分:2)

你有SERVICE_STATUS结构

具体值意味着下一个:

dwServiceType=SERVICE_WIN32_OWN_PROCESS(16)
dwCurrentState=SERVICE_RUNNING(4)
dwControlsAccepted=SERVICE_ACCEPT_SESSIONCHANGE|SERVICE_ACCEPT_POWEREVENT|SERVICE_ACCEPT_SHUTDOWN|SERVICE_ACCEPT_STOP (0xc5==197)
dwWin32ExitCode=NO_ERROR (0)
dwServiceSpecificExitCode=0 // This value is ignored because dwWin32ExitCode != ERROR_SERVICE_SPECIFIC_ERROR.
dwCheckPoint=0
dwWaitHint=0

答案 1 :(得分:0)

win32serviceutil [GitHub]: mhammond/pywin32 - Python for Windows (pywin32) Extensions的一部分,它是 Python WINAPI 上的包装。

  • [ActiveState.Docs]: win32service.QueryServiceStatus(这是我能找到的最接近官方 PyWin32 doc的文件)是[MS.Docs]: QueryServiceStatus function上的包装并返回[ActiveState.Docs]: SERVICE_STATUS Object (元组)

    Items:
    [0] int : serviceType
            The type of service.
    [1] int : serviceState
            The current state of the service.
    [2] int : controlsAccepted
            The controls the service accepts.
    [3] int : win32ExitCode
            The win32 error code for the service.
    [4] int : serviceSpecificErrorCode
            The service specific error code.
    [5] int : checkPoint
            The checkpoint reported by the service.
    [6] int : waitHint
            The wait hint reported by the service.
    
  • win32serviceutil.QueryServiceStatus是前一个的简写(它封装了所有其他相关的调用:win32service.OpenSCManagerwin32service.OpenServicewin32service.CloseServiceHandle)并返回相同的内容< / p>