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

问题描述 投票:1回答:2

我正在学习使用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

python winapi pywin32
2个回答
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

0
投票

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

  • [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)并返回相同的东西
© www.soinside.com 2019 - 2024. All rights reserved.