IDebugThread2::GetThreadProperties
如需 Visual Studio 2017 的最新文件請參閱 Visual Studio 2017 文件。
取得描述這個執行緒的屬性。
語法
HRESULT GetThreadProperties (
THREADPROPERTY_FIELDS dwFields,
THREADPROPERTIES* ptp
);
int GetThreadProperties (
enum_THREADPROPERTY_FIELDS dwFields,
THREADPROPERTIES[] ptp
);
參數
dwFields
[in]從旗標的組合THREADPROPERTY_FIELDS列舉,決定哪些欄位的ptp
要進行填寫。
ptp
[in、 out]A THREADPROPERTIES結構,填入這些執行緒的內容。
傳回值
如果成功,傳回S_OK
; 否則傳回錯誤碼。
備註
從這個方法傳回的資訊通常會顯示在執行緒偵錯視窗。
範例
下列範例示範如何實作這種簡單的方式CProgram
實作物件IDebugThread2介面。
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;
}