Partager via


MÉTHODE IDWriteLocalizedStrings::GetStringLength (dwrite.h)

Obtient la longueur en caractères (sans inclure la marque de fin Null) de la chaîne avec l’index spécifié.

Syntaxe

HRESULT GetStringLength(
        UINT32 index,
  [out] UINT32 *length
);

Paramètres

index

Type : UINT32

Index de base zéro de la paire langue/chaîne.

[out] length

Type : UINT32*

Longueur en caractères de la chaîne, à l’exception de la marque de fin Null, de la paire langue/chaîne.

Valeur retournée

Type : HRESULT

Si cette méthode réussit, elle retourne S_OK. Sinon, elle retourne un code d’erreur HRESULT.

Notes

Utilisez GetStringLength pour obtenir la longueur de chaîne avant d’appeler la méthode IDWriteLocalizedStrings::GetString , comme indiqué dans le code suivant.

UINT32 length = 0;

// Get the string length.
if (SUCCEEDED(hr))
{
    hr = pFamilyNames->GetStringLength(index, &length);
}

// Allocate a string big enough to hold the name.
wchar_t* name = new (std::nothrow) wchar_t[length+1];
if (name == NULL)
{
    hr = E_OUTOFMEMORY;
}

// Get the family name.
if (SUCCEEDED(hr))
{
    hr = pFamilyNames->GetString(index, name, length+1);
}

Spécifications

   
Client minimal pris en charge Windows 7, Windows Vista avec SP2 et Mise à jour de plateforme pour Windows Vista [applications de bureau | Applications UWP]
Serveur minimal pris en charge Windows Server 2008 R2, Windows Server 2008 avec SP2 et Platform Update pour Windows Server 2008 [applications de bureau | Applications UWP]
Plateforme cible Windows
En-tête dwrite.h
Bibliothèque Dwrite.lib
DLL Dwrite.dll

Voir aussi

IDWriteLocalizedStrings