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