共用方式為


IDebugHostType::GetBitField 方法 (dbgmodel.h)

如果數據結構的特定成員是位欄位(例如:ULONG MyBits:8),則欄位的類型資訊會攜帶位字位位置的相關信息。 GetBitField 方法可用來擷取該資訊。 此方法會在任何不是位欄位的類型上失敗。 這是方法失敗的唯一原因。 只要呼叫此方法並查看成功/失敗就足以區分位字段與非位字段。

如果指定的類型確實是位字段,字段位置是由半開啟集所定義(lsbOfField + lengthOfField : lsbOfField]

語法

HRESULT GetBitField(
  ULONG *lsbOfField,
  ULONG *lengthOfField
);

參數

lsbOfField

表示字段的最小有效位(其中 0 定義為包含類型的最小有效位)。 根據 lengthOfField 自變數所指定的長度,將位字段定義為利用這個點到包含類型最顯著位的位。

lengthOfField

欄位中的位數。 這至少會是一個,而且不超過包含型別中的位數目。 根據此處傳回的位數,位字段會從 lsbOfField 自變數中指定的位向上佔用到包含值的最大有效位。

傳回值

此方法會傳回表示成功或失敗的 HRESULT。

言論

範例程式代碼

ComPtr<IDebugHostType> spType; /* get the type of a field which is a bitmap */

ULONG lsb;
ULONG length;
if (SUCCEEDED(spType->GetBitField(&lsb, &length)))
{
    // spType refers to a bitfield.  The field is [lsb, lsb + length) in 
    // bit positions.  Were you to read memory at the location/size specified 
    // by an object of this type, you would need to mask off bits at and 
    // above 'lsb + length' and shift right by 'lsb'
    //
    // Note that IModelObject::GetRawObject will automatically do this for you. 
    // So will creating an object with this type spType via CreateTypedObject.
}

要求

要求 價值
標頭 dbgmodel.h

另請參閱

IDebugHostType 介面