Partager via


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

Copie la chaîne avec l’index spécifié dans le tableau spécifié.

Syntaxe

HRESULT GetString(
        UINT32 index,
  [out] WCHAR  *stringBuffer,
        UINT32 size
);

Paramètres

index

Type : UINT32

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

[out] stringBuffer

Type : WCHAR*

Tableau de caractères terminé par null qui reçoit la chaîne de la paire langue/chaîne. La mémoire tampon allouée pour ce tableau doit être d’au moins la taille. GetStringLength peut être utilisé pour obtenir la taille du tableau avant d’utiliser cette méthode.

size

Type : UINT32

Taille du tableau en caractères. La taille doit inclure de l’espace pour le caractère null de fin. GetStringLength peut être utilisé pour obtenir la taille du tableau avant d’utiliser cette méthode.

Valeur retournée

Type : HRESULT

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

Remarques

La chaîne retournée doit être allouée par l’appelant. Vous pouvez obtenir la taille de la chaîne à l’aide de la méthode GetStringLength avant d’appeler GetString, comme illustré dans l’exemple 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);
}

Configuration requise

Condition requise Valeur
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