Share via


Metodo IDWriteLocalizedStrings::GetStringLength (dwrite.h)

Ottiene la lunghezza in caratteri (non incluso il terminatore Null) della stringa con l'indice specificato.

Sintassi

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

Parametri

index

Tipo: UINT32

Indice in base zero della coppia lingua/stringa.

[out] length

Tipo: UINT32*

Lunghezza in caratteri della stringa, non inclusa la terminazione Null, dalla coppia lingua/stringa.

Valore restituito

Tipo: HRESULT

Se questo metodo ha esito positivo, restituisce S_OK. In caso contrario, restituisce un codice di errore HRESULT .

Commenti

Usare GetStringLength per ottenere la lunghezza della stringa prima di chiamare il metodo IDWriteLocalizedStrings::GetString , come illustrato nel codice seguente.

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);
}

Requisiti

   
Client minimo supportato Windows 7, Windows Vista con SP2 e Aggiornamento della piattaforma per Windows Vista [app desktop | App UWP]
Server minimo supportato Windows Server 2008 R2, Windows Server 2008 con SP2 e Platform Update per Windows Server 2008 [app desktop | App UWP]
Piattaforma di destinazione Windows
Intestazione dwrite.h
Libreria Dwrite.lib
DLL Dwrite.dll

Vedi anche

IDWriteLocalizedStrings