IDebugThread2::GetThreadProperties

获取描述此线程的属性。

语法

int GetThreadProperties (
    enum_THREADPROPERTY_FIELDS dwFields,
    THREADPROPERTIES[]         ptp
);

参数

dwFields
[in]THREADPROPERTY_FIELDS枚举中的标志的组合,用于确定要填充哪些字段ptp

ptp
[in, out]使用 线程属性填充的 THREADPROPERTIES 结构。

返回值

如果成功,则返回 S_OK;否则,返回错误代码。

注解

此方法返回的信息通常显示在 “线程 调试”窗口中。

示例

以下示例演示如何为实现 IDebugThread2 接口的简单CProgram对象实现此方法。

HRESULT CProgram::GetThreadProperties(THREADPROPERTY_FIELDS dwFields,
                                      THREADPROPERTIES *ptp)
{
    HRESULT hr = E_FAIL;

    // Check for valid argument.
    if (ptp)
    {
        // Create an array of buffers at ptp the size of the
        // THREADPROPERTIES structure and set all of the
        // buffers at ptp to 0.
        memset(ptp, 0, sizeof (THREADPROPERTIES));

        // Check if there is a valid THREADPROPERTY_FIELDS and the TPF_ID flag is set.
        if (dwFields & TPF_ID)
        {
            // Check for successful assignment of the current thread ID to
            // the dwThreadId of the passed THREADPROPERTIES.
            if (GetThreadId(&(ptp->dwThreadId)) == S_OK)
            {
                // Set the TPF_ID flag in the THREADPROPERTY_FIELDS enumerator
                // of the passed THREADPROPERTIES.
                ptp->dwFields |= TPF_ID;
            }
        }

        hr = S_OK;
    }
    else
        hr = E_INVALIDARG;

    return hr;
}

另请参阅