Directory Services |
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.
Property | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Status
[Visual Basic] [C++] |
Status of service. The following table lists
possible values.
|
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
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();
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.
IADsFileService, IADsFileServiceOperations, IADsService, IADsServiceOperations