IDataModelManager::CreateTypedIntrinsicObject 方法 (dbgmodel.h)
CreateTypedintrinsicObject 方法類似於 CreateIntrinsicObject 方法,不同之處在於它允許原生/語言類型與數據相關聯,並連同 Boxed 值一起攜帶。 這可讓數據模型代表像是原生列舉型別的建構(這隻是VT_UI* 或VT_I* 值)。 指標類型也會使用這個方法建立。 數據模型中的原生指標是零個延伸的64位數量,代表位移到偵錯目標的虛擬位址空間。 它會在VT_UI8內方塊化,並使用此方法和表示原生/語言指標的類型來建立。
語法
HRESULT CreateTypedIntrinsicObject(
VARIANT *intrinsicData,
IDebugHostType *type,
IModelObject **object
);
參數
intrinsicData
VARIANT,其中包含將在 IModelObject 容器內方塊化的值。 請注意,此方法不支援VT_UNKNOWN建構。 傳遞至這個方法的任何項目都必須可表示為 ObjectIntrinsic。
type
值的原生/語言類型。
object
新 boxed 值 (作為 IModelObject)將會在這裡傳回。
傳回值
此方法會傳回表示成功或失敗的 HRESULT。
言論
範例程式代碼
ComPtr<IDataModelManager> spManager; /* get the data model manager */
ComPtr<IDebugHostType> spEnumType; /* get an enum type (see CreateTypedObject) */
ComPtr<IDebugHostType> spPtrType; /* get a pointer type (see CreateTypedObject) */
// Box an enum
VARIANT vtEnumValue;
vtEnumValue.vt = VT_I4;
vtEnumValue.lVal = 2;
ComPtr<IModelObject> spEnumValue;
if (SUCCEEDED(spManager->CreateTypedIntrinsicObject(&vtEnumValue,
spEnumType.Get(),
&spEnumValue)))
{
// spEnumValue now contains the value '2' expressed as the enum type
// in spEnumType. The value will still present as 2 and operate as any other int.
// A type query on the object will, however, yield the enum type.
}
// Box a pointer. All pointers are represented as unsigned 64-bit values.
// 32-bit pointers are **ZERO EXTENDED** to 64-bits.
VARIANT vtPtrValue;
vtPtrValue.vt = VT_UI8;
vtPtrValue.ullVal = 0x100; // the pointer address
ComPtr<IModelObject> spPtrValue;
if (SUCCEEDED(spManager->CreateTypedIntrinsicObject(&vtPtrValue, spPtrType.Get(), &spPtrValue)))
{
// spPtrValue now contains a <TYPE (POINTER)>(0x100). You can fetch
// the pointer address through standard means of GetIntrinsicValue(As).
// Dereference() will work on spPtrValue!
}
要求
要求 | 價值 |
---|---|
標頭 | dbgmodel.h |