IDataModelManager2::CreateTypedIntrinsicObject 方法 (dbgmodel.h)

CreateTypedintrinsicObject 方法類似於 CreateIntrinsicObject 方法,不同之處在於它允許原生/語言類型與數據產生關聯,並隨附 Boxed 值。 這可讓數據模型代表原生列舉型別 (這類建構,這些類型只是VT_UI* 或VT_I* 值) 。 指標類型也會使用這個方法建立。 數據模型中的原生指標是零擴充的64位數量,代表偵錯目標虛擬位址空間的位移。 它會在VT_UI8內建立,並使用這個方法建立,以及指出原生/語言指標的類型。

語法

HRESULT CreateTypedIntrinsicObject(
  VARIANT        *intrinsicData,
  IDebugHostType *type,
  IModelObject   **object
);

參數

intrinsicData

VARIANT,其中包含要在 IModelObject 容器內Boxd的值。 請注意,這個方法不支援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

另請參閱

IDataModelManager2 介面