共用方式為


IModelObject::GetContext 方法 (dbgmodel.h)

GetContext 方法會傳回與 對象相關聯的主機內容。 這代表目標、進程、線程等...物件來自 。

語法

HRESULT GetContext(
  IDebugHostContext **context
);

參數

context

物件的主機內容將會在此自變數中傳回。

傳回值

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

言論

程式代碼範例

ComPtr<IDebugHost> spHost;      // get the debug host
ComPtr<IModelObject> spObject;  // get an object within a process (or a process object)

ComPtr<IDebugHostContext> spContext;
ComPtr<IDebugHostMemory> spMemory;
if (SUCCEEDED(spObject->GetContext(&spContext)) &&
    SUCCEEDED(spHost.As(&spMemory)))
{
    // Read 4 bytes from address 0x100 in the process context represented by spObject
    char bytes[4];
    ULONG64 bytesRead;
    HRESULT hr = spMemory->ReadBytes(spContext.Get(), 0x100, bytes, ARRAYSIZE(bytes), &bytesRead);
    
    // Check / Use read.
}

要求

要求 價值
標頭 dbgmodel.h

另請參閱

IModelObject 介面