GetAcceptLanguages function

Retrieves a string used with websites when specifying language preferences.


HRESULT GetAcceptLanguages(
  _Out_   LPTSTR pszLanguages,
  _Inout_ DWORD  *pcchLanguages


pszLanguages [out]


A pointer to a string that, when this function returns successfully, receives the language preferences information. We recommend that this buffer be of size 2048 characters to ensure sufficient space to return the full string. You can also call this function with this parameter set to NULL to retrieve the size of the string that will be returned.

pcchLanguages [in, out]

Type: DWORD*

A pointer to the size, in characters, of the string at pszLanguages.

On entry, this value is the size of pszLanguages, including the terminating null character.

On exit, it is the actual size of pszLanguages, not including the terminating null character.

Return value


If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


For those versions of Windows that do not include GetAcceptLanguages in Shlwapi.h, this function's individual ANSI or Unicode version must be called directly from Shlwapi.dll. GetAcceptLanguagesA is ordinal 14 and GetAcceptLanguagesW is ordinal 15.

Some websites offer content in multiple languages. You can specify your language preferences in the Internet Options item in Control Panel. GetAcceptLanguages retrieves a string that represents those preferences. That string is sent in an additional language header when negotiating HTTP connections.

Note  If your app or service passes language tags from this function to any National Language Support functions, or to Microsoft .NET, it must first convert the tags through the ResolveLocaleName function.


Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]






Shlwapi.dll (version 5.0 or later)

Unicode and ANSI names

GetAcceptLanguagesW (Unicode) and GetAcceptLanguagesA (ANSI)