IDebugThread2::GetThreadProperties

Obtient les propriétés qui décrivent ce thread.

Syntaxe

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

Paramètres

dwFields
[in] Combinaison d’indicateurs de l’énumération THREADPROPERTY_FIELDS qui détermine les champs à ptp remplir.

ptp
[in, out] Structure THREADPROPERTIES remplie avec les propriétés du thread.

Valeur de retour

En cas de réussite, retourne S_OK , sinon, retourne un code d'erreur.

Notes

Les informations retournées à partir de cette méthode sont généralement affichées dans la fenêtre de débogage Threads .

Exemple

L’exemple suivant montre comment implémenter cette méthode pour un objet simple CProgram qui implémente l’interface 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;
}

Voir aussi