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 |