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.

Syntax

BOOL SetUserGeoName(
  [in] PWSTR geoName
);

Parameters

[in] 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
ERROR_ACCESS_DISABLED_BY_POLICY
The group policy of the computer or the user has forbidden this operation.
ERROR_INTERNAL_ERROR
An unexpected error occurred in the function.
ERROR_INVALID_PARAMETER
A parameter value was invalid.

Remarks

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.

Requirements

Requirement Value
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

EnumSystemGeoNames

GetUserDefaultGeoName

National Language Support

National Language Support Functions

SetUserGeoID