Python win32serviceutil QueryServiceStatus: What does the return value mean?

天涯浪子 提交于 2019-12-11 07:36:30

问题


I am learning to use pywin32, and am trying to use the win32serviceutil modules on 64bit Python 3.6.4

The following code:

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

Returns the following tuple:

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

I am utterly new to the windows api and pywin32, what does these 6 values mean? Any documentation on pywin32 and win32 isn't revealing anything.

Edit - I'm running Windows 10


回答1:


you got SERVICE_STATUS structure

the concrete values mean next:

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



回答2:


win32serviceutil is part of [GitHub]: mhammond/pywin32 - Python for Windows (pywin32) Extensions, which is a Python wrapper over WINAPIs.

  • [ActiveState.Docs]: win32service.QueryServiceStatus (this is the closest that I could find of an official PyWin32 doc) is an wrapper over [MS.Docs]: QueryServiceStatus function and returns an [ActiveState.Docs]: SERVICE_STATUS Object (tuple)

    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 is a shorthand over the previous (it encapsulates all the other involved calls: win32service.OpenSCManager, win32service.OpenService, win32service.CloseServiceHandle) and returns the same thing



来源:https://stackoverflow.com/questions/48851473/python-win32serviceutil-queryservicestatus-what-does-the-return-value-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!