Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsServiceOperations::Stop method stops a currently active service on the network.
HRESULT IADsServiceOperations::Stop(void);
This method supports the standard return values, including S_OK. For other return values, see ADSI Error Codes.
The following Visual Basic code snippet shows how to stop 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.Stop End If
The following C++ code snippet stops 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->Stop(); pSrvOp->Release();
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.