IModelObject::EnumerateKeyValues 方法 (dbgmodel.h)
EnumerateKeyValues 方法是用戶端將轉換成的第一種方法,以便列舉物件上的所有索引鍵(這包括父模型樹狀結構中任何位置實作的所有索引鍵)。 請務必注意,EnumerateKeyValues 會列舉物件樹狀結構中重複名稱所定義的任何索引鍵:不過 -- GetKeyValue 和 SetKeyValue 等方法只會作具有深度優先周遊所探索指定名稱之索引鍵的第一個實例。
語法
HRESULT EnumerateKeyValues(
IKeyEnumerator **enumerator
);
參數
enumerator
物件上所有索引鍵的列舉值(及其所有父模型)及其值和元數據都會在此自變數中傳回為 IKeyEnumerator。
傳回值
此方法會傳回表示成功或失敗的 HRESULT。
言論
程式代碼範例
ComPtr<IModelObject> spObject; /* get the object you want to enumerate */
ComPtr<IKeyEnumerator> spEnum;
if (SUCCEEDED(spObject->EnumerateKeyValues(&spEnum)))
{
HRESULT hr = S_OK;
while (SUCCEEDED(hr))
{
BSTR keyName;
ComPtr<IModelObject> spKeyValue;
hr = spEnum->GetNext(&keyName, &spKeyValue, nullptr);
if (SUCCEEDED(hr))
{
// keyName contains the name of the key
// spKeyValue contains the value of the key
SysFreeString(keyName);
}
}
// hr == E_BOUNDS : We hit the end of the enumerator
// hr == E_ABORT : User is requesting interruption of the
// operation / stop immediately and flow the error
}
要求
要求 | 價值 |
---|---|
標頭 | dbgmodel.h |