ICertManageModule::GetProperty 方法 (certmod.h)

GetProperty 方法 检索模块的属性值。

语法

HRESULT GetProperty(
  [in]          const BSTR strConfig,
  [in]          BSTR       strStorageLocation,
  [in]          BSTR       strPropertyName,
  [in]          LONG       Flags,
  [out, retval] VARIANT    *pvarProperty
);

参数

[in] strConfig

表示 COMPUTERNAME\CANAME 形式的证书服务服务器的配置字符串,其中 COMPUTERNAME 是证书服务服务器的网络名称,CANAME 是证书服务设置期间为 CA 输入的 证书颁发机构(CA)的公用名。 有关配置字符串名称的信息,请参阅 ICertConfig

[in] strStorageLocation

一个注册表项,表示属性值的 HKEY_LOCAL_MACHINE 配置单元中的存储位置。 此值采用以下形式:

SYSTEM
   CurrentControlSet
      Services
         CertSvc
            Configuration
               CAName
                  PolicyOrExitModules
                     MyModule.PolicyOrExit

CAName 是证书颁发机构的配置字符串的名称,PolicyOrExitModules 将是“Policy”或“Exit”(具体取决于策略或 Exit 模块是否适用于此实现 ICertManageModule),MyModule.PolicyOrExit 是模块的应用程序特定标识符。 请注意,CAName 是证书颁发机构的 清理名称。 有关清理名称的信息,请参阅 ICertConfig::GetConfig。 使用此存储位置是为了将来使用。

[in] strPropertyName

要查询的属性的名称。 策略和退出模块应支持以下属性。

价值 意义
名称
模块的名称。
说明
模块的说明。
版权
与模块相关的版权。
文件版本
模块文件的版本。
产品版本
模块的版本。

[in] Flags

此参数是保留的,必须设置为零。

[out, retval] pvarProperty

指向 VARIANT 的指针,它是由 strPropertyName指定的属性的检索值。

返回值

C++

如果方法成功,该方法将返回S_OK。

如果方法失败,它将返回指示错误的 HRESULT 值。 有关常见错误代码的列表,请参阅 常见 HRESULT 值

VB

返回值是一个 Variant,表示 strPropertyName名为 的属性的值。

言论

实现 ICertManageModule 允许证书服务管理器通过调用 GetProperty来检索模块的属性。 然后,可以在策略和退出模块的 Certificate Services Manager 属性页中显示这些属性。 证书服务管理器会将由 strStorageLocation 引用的位置传递给此模块,在将来的版本中,此方法的实现可以根据需要使用此位置。 以下示例不使用 strStorageLocation,而是在内存中维护属性值。

例子

#include <windows.h>
#include <Certmod.h>

HRESULT CCertManagePolicyModule::GetProperty(
            /* [in] */ const BSTR strConfig,
            /* [in] */ BSTR strStorageLocation,
            /* [in] */ BSTR strPropertyName,
            /* [in] */ LONG Flags,
            /* [retval][out] */ VARIANT *pvarProperty)
{
    // Array of property Names.
    // These values are defined in Certmod.h.
    wchar_t const * awszPropName[] =
    {
        wszCMM_PROP_NAME,
        wszCMM_PROP_DESCRIPTION,
        wszCMM_PROP_COPYRIGHT,
        wszCMM_PROP_FILEVER,
        wszCMM_PROP_PRODUCTVER
    };

    // Array of property Values.
    // These values are module-specific, and
    // correspond to the property names in    
    // awszPropName (same index).
    wchar_t const * awszPropValue[] = 
   {
        L"MyModule",                      // NAME
        L"Description of MyModule",       // DESCRIPTION
        L"Copyright 1998",                // COPYRIGHT
        L"1.0",                           // FILE VERSION
        L"1.0"                            // PRODUCT VERSION
    };
    int     i;
    bool    bFound = FALSE;
    HRESULT hr;

    // Return appropriate error if strPropertyName is NULL.
    if (NULL == strPropertyName)
        return E_INVALIDARG;

    // Return appropriate error if pvarProperty is NULL.
    if (NULL == pvarProperty)
        return E_POINTER;
    // Determine whether the requested property is in the Name array.
    for (i=0; i<sizeof(awszPropName)/sizeof(wchar_t *); i++)
        if (!wcscmp( strPropertyName, awszPropName[i]))        
        {
            bFound = TRUE;  // Found the index for the property.
            break;
        }
    if ( !bFound )
        return S_FALSE;     // Requested property not found.

    // Allocate storage for the property value.
    pvarProperty->bstrVal = SysAllocString(awszPropValue[i]);
    if (NULL == pvarProperty->bstrVal)
        return E_OUTOFMEMORY;   

    pvarProperty->vt = VT_BSTR;

    return S_OK;
}

要求

要求 价值
最低支持的客户端 不支持
支持的最低服务器 Windows Server 2003 [仅限桌面应用]
目标平台 窗户
标头 certmod.h (包括 Certsrv.h)
Certidl.lib

另请参阅

CCertManageModule

ICertConfig

ICertManageModule

ICertManageModule::SetProperty