GetGeoInfoA function (winnls.h)
[GetGeoInfo is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use GetGeoInfoEx.
]
Retrieves information about a specified geographical location.
Syntax
int GetGeoInfoA(
[in] GEOID Location,
[in] GEOTYPE GeoType,
[out, optional] LPSTR lpGeoData,
[in] int cchData,
[in] LANGID LangId
);
Parameters
[in] Location
Identifier for the geographical location for which to get information. For more information, see Table of Geographical Locations. You can obtain the available values by calling EnumSystemGeoID.
[in] GeoType
Type of information to retrieve. Possible values are defined by the SYSGEOTYPE enumeration. If the value of GeoType is GEO_LCID, the function retrieves a locale identifier. If the value of GeoType is GEO_RFC1766, the function retrieves a string name that is compliant with RFC 4646 (Windows Vista). For more information, see the Remarks section.
Windows XP: When GeoType is set to GEO_LCID, the retrieved string is an 8-digit hexadecimal value.
Windows Me: When GeoType is set to GEO_LCID, the retrieved string is a decimal value.
[out, optional] lpGeoData
Pointer to the buffer in which this function retrieves the information.
[in] cchData
Size of the buffer indicated by lpGeoData. The size is the number of bytes for the ANSI version of the function, or the number of words for the Unicode version. The application can set this parameter to 0 if the function is to return the required size of the buffer.
[in] LangId
Identifier for the language, used with the value of Location. The application can set this parameter to 0, with GEO_RFC1766 or GEO_LCID specified for GeoType. This setting causes the function to retrieve the language identifier by calling GetUserDefaultLangID.
Return value
Returns the number of bytes (ANSI) or words (Unicode) of geographical location information retrieved in the output buffer. If cchData is set to 0, the function returns the required size for the buffer.
The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:
- ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
- ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.
Remarks
If the application specifies GEO_RFC1766 for GeoType, it should specify a language identifier for LangId that is appropriate to the specified geographical location identifier. The appropriate language is either a locale-neutral language or one with a locale corresponding to the specified identifier. The resulting string, compliant with RFC 4646 (Windows Vista), constitutes a locale name.
For example, if Location is specified as 0xF4 for United States, GeoType is specified as GEO_RFC1766, and LangId is specified as either 0x09 for locale-neutral English or 0x409 for English (United States), the function retrieves "en-US" on successful return. In fact, the function ignores the locale-specific portion of the language. Thus, if the application specifies LangId as 0x809 for English (United Kingdom), the function also writes "en-US" to lpGeoData.
Consider another example. If Location is specified as 0xF4 for United States, GeoType is specified as GEO_RFC1766, and LangId is specified as 0x04 for Chinese, the function retrieves "zh-US" on successful return. This is not the name of a supported locale.
If the application specifies GEO_LCID for GeoType, the function treats the language identifier as a locale identifier (LCID). It attempts to return the locale identifier if it is associated with the provided geographical identifier in some way.
Note
The winnls.h header defines GetGeoInfo as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2003 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | winnls.h (include Windows.h) |
Library | Kernel32.lib |
DLL | Kernel32.dll |