Информация о регионе ОС

audiofeel

Старожил
Привет. Требуется вывести инфу о регионе ОС. Нашел решение...

code_language.pascal:
function GetUserDefaultGeoName(GeoName: string; GeoNameCount: Integer): Integer;
  external 'GetUserDefaultGeoName@Kernel32.dll stdcall';

function GetGeoName: string;
begin
  SetLength(Result, 100);
  SetLength(Result, GetUserDefaultGeoName(Result, Length(Result)));
end;
----------------------
AutorunLbl.Text(GetGeoName);
Возвращает только EN, UK RU и тд. Хотелось бы полностью - допустим Венгрия, Польша Россия и тд. Или это не возможно?
 

Хамик

Старожил
В WinApi не силен, но можно все вручную прописать
code_language.pascal:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
OutputDir=.
ShowLanguageDialog=auto

[Languages]
Name: "en"; MessagesFile: "compiler:Languages\English.isl";
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl";

[CustomMessages]
ru.GeoError=Не удалось определить регион.
en.GeoError=Failed to determine region.
ru.RU=Россия
en.RU=Russian
ru.EN=США
en.EN=USA
ru.UA=Украина
en.UA=Ukraine
ru.HU=Венгрия
en.HU=Hungary
ru.BE=Беларусь
en.BE=Belarus

[code]
function GetGeoCountry: string;
var
  country: array of string;
  buf: string;
begin
  SetArrayLength(country, 100);
  country := [CustomMessage('RU'), CustomMessage('EN'), CustomMessage('UA'), CustomMessage('HU'), CustomMessage('BE')];
  RegQueryStringValue(HKCU, 'Control Panel\International\Geo', 'Name', buf);
  if (buf = '') then MsgBox(CustomMessage('GeoError'), mbInformation, MB_OK) else
  case AnsiLowercase(buf) of
    'ru': Result := country[0];
    'en': Result := country[1];
    'ua': Result := country[2];
    'hu': Result := country[3];
    'be': Result := country[4];
  end;
end;

procedure InitializeWizard();
begin
  MsgBox(GetGeoCountry, mbInformation, MB_OK);
end;
 
Последнее редактирование:
Сверху