IDebugThread2::GetThreadProperties
取得描述這個線程的屬性。
語法
參數
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;
}