Freigeben über


IDWriteLocalizedStrings::GetStringLength Method

Gets the length in characters (not including the null terminator) of the string with the specified index.

Syntax

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

Parameter

  • index
    A zero-based index of the language/string pair.

  • length [out]
    The length in characters of the string, not including the null terminator, from the language/string pair.

Rückgabewert

Ist Methode erfolgreich, wird "S_OK" zurückgegeben. Andernfalls wird ein HRESULT-Fehlercode zurückgegeben.

Hinweise

Use GetStringLength to get the string length before calling the IDWriteLocalizedStrings::GetString method, as shown in the following code.

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

Anforderungen

Mindestens unterstützter Client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista

Mindestens unterstützter Server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008

Header

Dwrite.h

Bibliothek

Dwrite.lib

DLL

Dwrite.dll

Siehe auch

IDWriteLocalizedStrings