SQLExpress - Xb2.NET
ot4xb
Search
Start
>
Forums
>
ot4xb.examples (readonly)
>
Retrieving a list of services with the status Active
ot4xb.examples (readonly)
Retrieving a list of services with the status Active
Thread Starter:
Pablo Botella
Started:
7/13/2008 3:41 PM UTC
Replies:
0
7/13/2008 3:41 PM UTC
Retrieving a list of services with the status Active
Pablo Botella
function aGetActiveServices()
local hSc := @advapi32:OpenSCManagerA(0,0,SC_MANAGER_ENUMERATE_SERVICE)
local lResult
local pData,cbData
local nRH := 0 // Resume Handle
local cbNeeded := 0
local nSvcCnt := 0
local lLoop := .T.
local aSvc := {}
local n,ns
if( hSc == 0 ) ; return {} ; end
cbData := 0x10000 ; pData := _xgrab(cbData)
while lLoop
nSvcCnt := 0
lResult := ( @advapi32:EnumServicesStatusExA( hSc,SC_ENUM_PROCESS_INFO,;
nOr(SERVICE_DRIVER,SERVICE_WIN32),SERVICE_ACTIVE,pData,cbData,;
@cbNeeded,@nSvcCnt,@nRH,0) != 0 )
lLoop := (nFpGetLastError() == ERROR_MORE_DATA)
if( lResult .or. lLoop )
ns := 0
for n := 1 to nSvcCnt
aadd( aSvc , PeekDWord(pData,@ns, 11) )
aSvc[-1][1] := PeekStr(aSvc[-1][1],,-1)
aSvc[-1][2] := PeekStr(aSvc[-1][2],,-1)
next
end
if lLoop .and. ( cbNeeded > cbData )
_xfree( pData ); cbData := cbNeeded ; pData := _xgrab(cbData)
end
end
_xfree( pData )
@advapi32:CloseServiceHandle(hSc)
return aSvc
This message includes the following attachments:
ListActiveServices.zip