Code: Select all
lpServiceName := "WSearch"
if !(hSCManager := DllCall("Advapi32\OpenSCManager", "Ptr", 0, "Ptr", 0, UInt, SC_MANAGER_ALL_ACCESS := 0xF003F))
throw "OpenSCManager, last error: " A_LastError
if !(hService := DllCall("Advapi32\OpenService", "Ptr", hSCManager, "Str", lpServiceName, UInt, SERVICE_ALL_ACCESS := 0xF01FF))
throw "OpenService, last error: " A_LastError
VarSetCapacity(_SERVICE_STATUS, 7 * 4, 0)
if !(DllCall("Advapi32\QueryServiceStatus", "Ptr", hService, "Ptr", &_SERVICE_STATUS))
throw "QueryServiceStatus, last error: " A_LastError
dwCurrentState := NumGet(_SERVICE_STATUS, 4, "UInt")
if (dwCurrentState == (SERVICE_STOPPED := 0x1))
MsgBox stopped
else
MsgBox not stopped
this is for unicode btw, change the dllcalls if u need ansi