答案 0 :(得分:0)
您可以像这样使用RegionInfo
类:
String currentRegion= System.Globalization.RegionInfo.CurrentRegion.DisplayName;
答案 1 :(得分:0)
所以,我从powershell cmdlet Get-WinHomeLocation
中删除了它:
如果您声明以下类:
public static class GeoTools
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetUserGeoID(int GeoClass);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetGeoInfo(int Location,
uint GeoType,
StringBuilder GeoData,
int Length,
ushort LangID);
}
然后你可以:
uint GEO_FRIENDLYNAME = 8u;
var homeLocationGeoId=GeoTools.GetUserGeoID(16);
StringBuilder stringBuilder = new StringBuilder(256);
int geoInfo = GeoTools.GetGeoInfo(homeLocationGeoId,
GEO_FRIENDLYNAME,
stringBuilder,
256,
0);
var homeLocation = stringBuilder.ToString(); //yay!