通过


IFtpProviderConstruct::Construct 方法

从 IIS ApplicationHost.config 文件中 FTP 提供程序的配置设置中检索键/值对数组。

语法

HRESULT Construct( 
   SAFEARRAY * configurationEntries 
) 

parameters

术语 定义
configurationEntries [IN]指向 SAFEARRAY 的指针,其中包含 IIS 配置设置中的键/值对。

返回值

HRESULT。 可能的值包括(但并不限于)下表中的项。

说明
S_OK 指示操作成功。

备注

可以通过添加 <activation> 集合来指定 IIS ApplicationHost.config 文件中 FTP 提供程序的参数,该集合可能包含一系列 <providerData> 元素,这些元素列出了自定义 FTP 提供程序的其他设置。 每个 <providerData> 元素都与集合中的 <providerDefinitions> 一个条目配对,并包含一系列键/值对,其中包含特定于每个提供程序的信息。

以下配置摘录演示了 ApplicationHost.config 文件中的自定义 FTP 提供程序条目及其相关信息。

<system.ftpServer> 
   <providerDefinitions> 
      <add name="FtpDemo" 
         clsid="FtpDemo.DemoProvider" /> 
      <activation> 
         <providerData name="FtpDemo"> 
            <add key="one" value="1" /> 
            <add key="two" value="2" /> 
         </providerData> 
      </activation> 
   </providerDefinitions> 
</system.ftpServer> 

示例

下面的代码示例循环访问配置设置的数组,并将键/值对发送到调试流。

public: 
   STDMETHOD(Construct)(SAFEARRAY * configurationEntries) 
   { 
      CONFIGURATION_ENTRY * pArray; 
      HRESULT hr = S_OK; 
      LONG lLbound = 0; 
      LONG lUbound = 0; 
 
      OutputDebugString(L"IFtpProviderConstruct::Construct\n"); 
 
      // Retrieve the upper and lower bounds for the configuration array. 
      SafeArrayGetLBound( configurationEntries, 1, &lLbound ); 
      SafeArrayGetUBound( configurationEntries, 1, &lUbound ); 
 
      // Retrieve a pointer to the array of configuration settings. 
      hr = SafeArrayAccessData(configurationEntries, (void**)&pArray); 
      // Return an error if a failure occurs. 
      if (FAILED(hr)) 
      { 
         return hr; 
      } 
 
      // Loop through the array of configuration setttings and 
      // output the key/value pairs to the debug channel. 
      for(LONG Index = lLbound; Index <= lUbound; Index ++) 
      { 
         OutputDebugString(pArray[Index].bstrKey); 
         OutputDebugString(pArray[Index].bstrValue); 
      } 
 
      // Release the pointer to the array of configuration settings. 
      hr = SafeArrayUnaccessData(configurationEntries); 
      // Return an error if a failure occurs. 
      if (FAILED(hr)) 
      { 
         return hr; 
      } 
 
      return S_OK; 
   } 

要求

类型 说明
客户端 - Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10 上的 IIS 10.0
服务器 - Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016 上的 IIS 10.0
产品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
参考 ftpext.tlb

另请参阅

IFtpProviderConstruct 接口