Platform SDK: Active Directory, ADSI, and Directory Services

IADsServiceOperations Property Methods

The property methods of the IADsServiceOperations interface read and write the properties described in the following table. For a general discussion of property methods, see Interface Property Methods.

Properties in Vtable Order

Property Description
Status

[Visual Basic]
Access: Read
Data Type: LONG

[C++]
HRESULT get_Status
([out] LONG *pstatus)

Status of service. The values can be found in the following list:
  Status
ADS_SERVICE_STOPPED
ADS_SERVICE_START_PENDING
ADS_SERVICE_STOP_PENDING
ADS_SERVICE_RUNNING
ADS_SERVICE_CONTINUE_PENDING
ADS_SERVICE_PAUSE_PENDING
ADS_SERVICE_PAUSED
ADS_SERVICE_ERROR
ADS_SERVICE_OWN_PROCESS
ADS_SERVICE_SHARE_PROCESS
ADS_SERVICE_KERNEL_DRIVER
ADS_SERVICE_FILE_SYSTEM_DRIVER
ADS_SERVICE_BOOT_START
ADS_SERVICE_SYSTEM_START
ADS_SERVICE_AUTO_START
ADS_SERVICE_DEMAND_START
ADS_SERVICE_DISABLED
ADS_SERVICE_ERROR_IGNORE
ADS_SERVICE_ERROR_NORMAL
ADS_SERVICE_ERROR_SEVERE
ADS_SERVICE_ERROR_CRITICAL
Constant
0x00000001
0x00000002
0x00000003
0x00000004
0x00000005
0x00000006
0x00000007
0x00000008
0x00000010
0x00000020
0x00000001
0x00000002
SERVICE_BOOT_START
SERVICE_SYSTEM_START
SERVICE_AUTO_START
SERVICE_DEMAND_START
SERVICE_DISABLED
0
1
2
3

Example Code [Visual Basic]

The following Visual Basic code snippet shows how to examine the status of the Microsoft® Fax Service running on a Windows® 2000 Professional.

Dim cp As IADsComputer
Dim sr As IADsService
Dim so As IADsServiceOperations
Set cp = GetObject("WinNT://myMachine,computer")
Set sr = cp.GetObject("Service", "Fax")
Set so = sr
Select Case so.Status
Case ADS_SERVICE_STOPPED
MsgBox "Microsoft Fax Service has stopped."
Case ADS_SERVICE_RUNNING
MsgBox "Microsoft Fax Service is running."
Case ADS_SERVICE_PAUSED
MsgBox "Microsoft Fax Service has paused."
Case ADS_SERVICE_ERROR
MsgBox "Microsoft Fax Service has errors."
End Select

Example Code [C++]

The following C++ code snippet examines the status of the Microsoft Fax Service running on a Windows 2000 Professional.

IADsContainer *pCont;
IADsServiceOperations *pSrvOp;
LPWSTR adsPath = L"WinNT://myMachine,computer";

HRESULT hr = ADsGetObject(adsPath,
IID_IADsContainer,
(void**)&pCont);
if(FAILED(hr)) exit(hr);
IDispatch *pDisp;
hr = pCont->GetObject(L"Service",L"Fax",&pDisp);
pCont->Release();
if(FAILED(hr)) exit(hr);

hr = pDisp->QueryInterface(IID_IADsServiceOperations,(void**)&pSrvOp);
pDisp->Release();
if(FAILED(hr)) exit(hr);

long status;
hr = pSrvOp->get_Status(&status);
switch (status) {
case ADS_SERVICE_STOPPED:
printf("The service has stopped.\n");
break;
case ADS_SERVICE_RUNNING:
printf("The service is running.\n");
break;
case ADS_SERVICE_PAUSED:
printf("The service has paused.\n");
break;
case ADS_SERVICE_ERROR:
printf("The service has errors.\n");
break;
}

pSrvOp->Release();

See Also

IADsFileService, IADsFileServiceOperations, IADsService, IADsServiceOperations