Platform SDK: Active Directory, ADSI, and Directory Services

IADsServiceOperations::Pause

The IADsServiceOperations::Pause method pauses a service that has been started with the IADsServiceOperations::Start method.

HRESULT IADsServiceOperations::Pause(void);

Return Values

This method supports the standard return values, including S_OK. For other return values, see ADSI Error Codes.

Example Code [Visual Basic]

The following Visual Basic code snippet shows how to pause a running Microsoft Fax Service on a Windows 2000 Professional.

Dim cp As IADsComputer
Dim so As IADsServiceOperations
Set cp = GetObject("WinNT://myMachine,computer")
Set so = cp.GetObject("Service", "Fax")
If (so.Status = ADS_SERVICE_RUNNING) then ' The operation is running.
so.Pause
End If

Example Code [C++]

The following C++ code snippet restarts 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);
if(status == ADS_SERVICE_RUNNING) pSrvop->Pause();

pSrvOp->Release();

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Iads.h.

See Also

IADsService, IADsServiceOperations::Start