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;
Parameters
- index
-
Type: UINT32
A zero-based index of the language/string pair.
- length [out]
-
Type: UINT32*
The length in characters of the string, not including the null terminator, from the language/string pair.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
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); }
Requirements
|
Minimum supported client |
Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps] |
|---|---|
|
Minimum supported server |
Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps] |
|
Minimum supported phone |
Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also