IBITSExtensionSetupFactory 介面 (bitscfg.h)

使用 IBITSExtensionSetupFactory 介面來取得 IBITSExtensionSetup 介面的指標。 只有在安裝 BITS 伺服器的安裝程式中使用 IBITSExtensionSetup 介面時,才使用此介面。 因為 IIS 快取不包含在安裝期間新增的 BITS 擴充功能,所以無法使用 ADsGetObject ADSI 函式來使用擴充功能。 IBITSExtensionSetupFactory 介面提供 GetObject 方法,此方法會存取 BITS 延伸模組,並執行與 ADsGetObject 函式相同的系結。

若要取得 IBITSExtensionSetupFactory 介面的指標,請呼叫 CoCreateInstance 函式,如範例程式代碼所示。

繼承

IBITSExtensionSetupFactory 介面繼承自 IUnknown 介面。 IBITSExtensionSetupFactory 也有下列類型的成員:

方法

IBITSExtensionSetupFactory 介面具有這些方法。

 
IBITSExtensionSetupFactory::GetObject

使用 GetObject 方法來擷取 IBITSExtensionSetup 介面的指標。 這個方法會執行 ADsGetObject ADSI 函式執行的相同系結。

備註

當您安裝 BITS 伺服器擴充功能時,此介面會在伺服器上註冊。

在 Windows Server 2003 上,使用 Windows 元件精靈 來安裝 BITS 伺服器擴充功能。 從 控制台,選取 [新增或移除程式]。 然後,選取 [新增/移除 Windows 元件 ] 以顯示 [Windows 元件精靈]。 BITS 伺服器延伸模組是 Internet Information Services (IIS) 的子元件,這是 Web 應用程式伺服器的子元件。

範例

下列範例示範如何使用 IBITSExtensionSetupFactory 介面來取得 IBITSExtensionSetup 介面的指標。

//Set the BITSUploadEnabled IIS configuration setting.
//The pszPath parameter contains the path to the directory service. 
//For example, "IIS://<machine name>/w3svc/1/<virtual directory>".
//The Enable parameter contains true (enable) or false (disable).
HRESULT SetBITSUploadEnabledSetting(LPWSTR pszPath, bool Enable)
{
  HRESULT hr;
  IBITSExtensionSetupFactory* pExtensionSetupFactory = NULL;
  IBITSExtensionSetup* pExtensionSetup = NULL;

  hr = CoCreateInstance(__uuidof(BITSExtensionSetupFactory),
    NULL, CLSCTX_INPROC_SERVER,
    __UUIDOF(IBITSExtensionSetupFactory),
    (void**)&pExtensionSetupFactory);

  if (SUCCEEDED(hr))
  {
    hr = pExtensionSetupFactory->GetObject(BSTR(pszPath), &pExtensionSetup);
    if (SUCCEEDED(hr))
    {
      if (Enable)
      {
        hr = pExtensionSetup->EnableBITSUploads();
      }
      else
      {
        hr = pExtensionSetup->DisableBITSUploads();
      }

      pExtensionSetup->Release();
    }
    pExtensionSetupFactory->Release();
  }

  return hr;
}

規格需求

需求
最低支援的用戶端 Windows Vista
最低支援的伺服器 Windows Server 2003
目標平台 Windows
標頭 bitscfg.h
可轉散發套件 Windows XP 上的 BITS 1.5

另請參閱

IBITSExtensionSetup