IVsUserContext.GetAttribute(Int32, String, Int32, String, String) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
基于索引位置或名称从上下文或子上下文包返回指定的特性或关键字。
public:
int GetAttribute(int iAttribute, System::String ^ pszName, int fIncludeChildren, [Runtime::InteropServices::Out] System::String ^ % pbstrName, [Runtime::InteropServices::Out] System::String ^ % pbstrValue);
int GetAttribute(int iAttribute, std::wstring const & pszName, int fIncludeChildren, [Runtime::InteropServices::Out] std::wstring const & & pbstrName, [Runtime::InteropServices::Out] std::wstring const & & pbstrValue);
public int GetAttribute (int iAttribute, string pszName, int fIncludeChildren, out string pbstrName, out string pbstrValue);
abstract member GetAttribute : int * string * int * string * string -> int
Public Function GetAttribute (iAttribute As Integer, pszName As String, fIncludeChildren As Integer, ByRef pbstrName As String, ByRef pbstrValue As String) As Integer
参数
- iAttribute
- Int32
中上下文或子上下文包中属性和关键字的集合的索引。
- pszName
- String
中特性名称或关键字。 指定属性名称以访问特定属性。 指定 "关键字" 可访问 F1 或 lookup 关键字。
- fIncludeChildren
- Int32
中如果为 true ,则还返回与上下文包关联的子上下文包。 如果 false 为,则排除子上下文。
- pbstrName
- String
弄指向特定属性名称或值关键字的指针(如果找到匹配项)。
- pbstrValue
- String
[out,retval]指向特定属性值或关键字文本的指针(如果找到匹配项)。
返回
如果该方法成功,则它会返回 S_OK。 如果该方法失败,则会返回错误代码。
注解
COM 签名
从上下文 .idl:
HRESULT IVsUserContext::GetAttribute(
[in] int iAttribute,
[in] LPCOLESTR pszName,
[in] BOOL fIncludeChildren,
[out] BSTR * pbstrName,
[out, retval] BSTR * pbstrValue
);
使用方法有三种不同的方法 IVsUserContext.GetAttribute :
传入以
null获取参数的值pszName,并使用参数循环访问上下文包中的所有属性和关键字iAttribute。 您可以使用方法确定上下文或子上下文包中属性和关键字的计数 CountAttributes 。循环访问所有属性和关键字,并传入参数值的特定属性名称或关键字
pszName。pbstrNamepbstrValue仅当你提供的名称与上下文或子上下文包中的名称匹配时,才在和参数中返回特性名称和值或关键字和值。为参数传递值-1
iAttribute,并为参数的值传入特定的特性名称或关键字pszName。 返回与该名称匹配的第一个属性或关键字。
如果此方法找到了该参数的匹配项 pszName ,则返回 S_OK 。 如果该方法没有找到匹配项,则返回 E_UNEXPECTED 。 因此,可以将 * pbstrName 和 * 参数的值设置 pbstrValue 为, null 并根据返回值评估方法是成功还是失败。
使用 GetAttributePri 方法可根据属性或关键字的优先级来访问它们。 有关优先级的详细信息,请参阅 VSUSERCONTEXTPRIORITY 。 使用 GetAttrUsage 方法确定从方法返回的关键字是否 IVsUserContext::GetAttribute 为 F1 或查找关键字。
如果上下文包没有任何子上下文,则参数的值不 fIncludeChildren 起作用。