Directory Services

IADsServiceOperations Property Methods

The property methods of the IADsServiceOperations interface read and write the properties described in the following table. For more information about property methods, see Interface Property Methods.

Properties

Property Description
Status

[Visual Basic]
Access: Read-only
DataType: Long

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

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

Example Code [Visual Basic]

The following code example shows how to verify the status of a Microsoft Fax Service running on Windows 2000.

Dim cp As IADsComputer
Dim sr As IADsService
Dim so As IADsServiceOperations
On Error GoTo Cleanup

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

Cleanup:
	If (Err.Number<>0) Then
		MsgBox("An error has occurred. " & Err.Number)
	End If
	Set cp = Nothing
	Set sr = Nothing
	Set so = Nothing

Example Code [C++]

The following code example verifies the status of a Microsoft Fax Service running on Windows 2000.

IADsContainer *pCont = NULL;
IADsServiceOperations *pSrvOp = NULL;
LPWSTR adsPath = L"WinNT://myMachine,computer";
IDispatch *pDisp = NULL;
long status = 0;

HRESULT hr = S_OK;

hr = ADsGetObject(adsPath,IID_IADsContainer,(void**)&pCont);
if(FAILED(hr)) {goto Cleanup;}

hr = pCont->GetObject(CComBSTR("Service"), CComBSTR("Fax"), &pDisp);
if(FAILED(hr)) {goto Cleanup;}

hr = pDisp->QueryInterface(IID_IADsServiceOperations,(void**)&pSrvOp);
if(FAILED(hr)) {goto Cleanup;}

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;
}

Cleanup:
	if(pDisp) pDisp->Release();
	if(pCont) pCont->Release();
	if(pSrvOp) pSrvOp->Release();

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

IADsFileService, IADsFileServiceOperations, IADsService, IADsServiceOperations