mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-01 10:39:45 -06:00
Core: use more recent api in ComputeDefaultCountryCode on Windows
Co-authored-by: Shawn Hoffman <godisgovernment@gmail.com>
This commit is contained in:
@ -90,13 +90,15 @@ static std::string ComputeDefaultCountryCode()
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Windows codepath: Check the regional information.
|
// Windows codepath: Check the regional information.
|
||||||
// More likely to match the user's physical location than locales are.
|
// More likely to match the user's physical location than locales are.
|
||||||
// TODO: Can we use GetUserDefaultGeoName? (It was added in a Windows 10 update)
|
const int buffer_size = GetUserDefaultGeoName(nullptr, 0);
|
||||||
GEOID geo = GetUserGeoID(GEOCLASS_NATION);
|
if (buffer_size == 3)
|
||||||
const int buffer_size = GetGeoInfoW(geo, GEO_ISO2, nullptr, 0, 0);
|
{
|
||||||
std::vector<wchar_t> buffer(buffer_size);
|
std::wstring buffer(buffer_size, L'\0');
|
||||||
const int result = GetGeoInfoW(geo, GEO_ISO2, buffer.data(), buffer_size, 0);
|
const int result = GetUserDefaultGeoName(buffer.data(), buffer_size);
|
||||||
if (result != 0)
|
buffer.resize(2);
|
||||||
return TStrToUTF8(buffer.data());
|
if (result > 0)
|
||||||
|
return WStringToUTF8(buffer);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Generic codepath: Check the locales.
|
// Generic codepath: Check the locales.
|
||||||
|
Reference in New Issue
Block a user