Share via


IDWriteLocalizedStrings::FindLocaleName Method

Gets the zero-based index of the locale name/string pair with the specified locale name.

Syntax

virtual HRESULT FindLocaleName(
  [in]   const WCHAR * localeName,
  [out]  UINT32 * index,
  [out]  BOOL * exists
) = 0;

Parameter

  • localeName [in]
    A null-terminated array of characters containing the locale name to look for.

  • index [out]
    The zero-based index of the locale name/string pair. This method initializes index to UINT_MAX.

  • exists [out]
    When this method returns, contains TRUE if the locale name exists; otherwise, FALSE. This method initializes exists to FALSE.

Rückgabewert

If the specified locale name does not exist, the return value is S_OK, but index is UINT_MAX and exists is FALSE.

Hinweise

Note that if the locale name does not exist, the return value is a success and the exists parameter is FALSE. If you are getting the font family name for a font and the specified locale name does not exist, one option is to set the index to 0 as shown below. There is always at least one locale for a font family.

UINT32 index = 0;
BOOL exists = false;

wchar_t localeName[LOCALE_NAME_MAX_LENGTH];

if (SUCCEEDED(hr))
{
    // Get the default locale for this user.
    int defaultLocaleSuccess = GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH);

    // If the default locale is returned, find that locale name, otherwise use "en-us".
    if (defaultLocaleSuccess)
    {
        hr = pFamilyNames->FindLocaleName(localeName, &index, &exists);
    }
    if (SUCCEEDED(hr) && !exists) // if the above find did not find a match, retry with US English
    {
        hr = pFamilyNames->FindLocaleName(L"en-us", &index, &exists);
    }
}

// If the specified locale doesn't exist, select the first on the list.
if (!exists)
    index = 0;

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