共用方式為


GetUserDefaultGeoName 函式 (winnls.h)

如果有的話,擷取使用者作為國際標準化組織 (ISO) 3166-1 兩個字母代碼的預設地理位置。 否則,聯合國(UN)系列 M,數位49(M.49)數位碼。

Syntax

int GetUserDefaultGeoName(
  [out] LPWSTR geoName,
  [in]  int    geoNameCount
);

Parameters

[out] geoName

緩衝區的指標,此函式應寫入以 Null 終止的國際標準標準化組織 (ISO) 3166-1 雙字母代碼或聯合國 (UN) 系列 M,數位 49 (M.49) 數值代碼。

[in] geoNameCount

The size of the buffer that the geoName parameter specifies. 如果此值為零,此函式只會傳回函式將複製到輸出緩衝區的字元數,但不會將用戶的預設地理位置名稱寫入緩衝區。

Return value

The number of characters the function would copy to the output buffer if the value of the geoNameCount parameter is zero. Otherwise, the number of characters that the function copied to the buffer that the geoName parameter specifies.

零表示函式失敗。 To get extended error information, call GetLastError, which can return one of the following error codes:

Return code Description
ERROR_INVALID_PARAMETER 參數值無效。
ERROR_BADDB 函式無法從登錄讀取資訊。
ERROR_INSUFFICIENT_BUFFER The buffer that the geoName parameter specifies is too small for the string.

Remarks

如果用戶預設地理位置的 ISO 3166-1 代碼是 'XX'(表示未指派任何程序代碼),但位置確實已指派 UN M.49 代碼,則會以十進位字串傳回 M.49 碼。

如需雙字母 ISO 3166-1 代碼的相關信息,請參閱 ISO 3166 國家/地區代碼

如需數值 UN M.49 代碼的相關信息,請參閱 標準國家/地區代碼進行統計使用 (M49)

Requirements

Requirement Value
最低支援的用戶端 Windows 10 版本 1709 [僅限傳統型應用程式]
支援的最低伺服器 Windows Server 2016 [僅限傳統型應用程式]
Target Platform Windows
Header winnls.h (包括 Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also