SetUserGeoName function (winnls.h)

Sets the geographic location for the current user to the specified two-letter International Organization for Standardization (ISO) 3166-1 code or numeric United Nations (UN) Series M, Number 49 (M.49) code.


BOOL SetUserGeoName(
  PWSTR geoName



The two-letter ISO 3166-1 or numeric UN M.49 code for the geographic location to set for the current user. To get the codes that are available on the operating system, call EnumSystemGeoNames.

Return value

Returns TRUE if successful or FALSE otherwise.

If this function does not succeed, call GetLastError, which can return one of the following error codes:

Return code Description
The group policy of the computer or the user has forbidden this operation.
An unexpected error occurred in the function.
A parameter value was invalid.


This function writes to the registry the geographical location for a particular user instead of a particular application. This action affects the behavior of other applications that the user runs. As a rule, call this function only when the user has explicitly requested changes, but not for purely application-specific reasons.

For information about two-letter ISO 3166-1 codes, see Country Codes - ISO 3166. For information about numeric UN M.49 codes, see Standard country or area codes for statistical use (M49).

SetUserGeoName is intended for use by applications that are designed to change user settings, such as the Windows Settings app. Other applications should not call this function.


Minimum supported client Windows 10, version 1709 [desktop apps only]
Minimum supported server Windows Server 2016 [desktop apps only]
Target Platform Windows
Header winnls.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also



National Language Support

National Language Support Functions