我正在学习使用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
你有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
win32serviceutil是[GitHub]: mhammond/pywin32 - Python for Windows (pywin32) Extensions的一部分,它是WINAPI上的Python包装器。
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.OpenSCManager
,win32service.OpenService
,win32service.CloseServiceHandle
)并返回相同的东西