David Heffernan 2345 Posted June 1, 2023 I came across this code in the RTL: function TRegistry.GetKeyInfo(var Value: TRegKeyInfo): Boolean; begin FillChar(Value, SizeOf(TRegKeyInfo), 0); Result := CheckResult(RegQueryInfoKey(CurrentKey, nil, nil, nil, @Value.NumSubKeys, @Value.MaxSubKeyLen, nil, @Value.NumValues, @Value.MaxValueLen, @Value.MaxDataLen, nil, @Value.FileTime)); if SysLocale.FarEast and (Win32Platform = VER_PLATFORM_WIN32_NT) then with Value do begin Inc(MaxSubKeyLen, MaxSubKeyLen); Inc(MaxValueLen, MaxValueLen); end; end; I'm wanting to call RegQueryInfoKey and wondering if I also need to mimic this far east if statement. I had a quick search on github for other code calling this function and can't see anything similar. Is it possible that this code is bogus? Share this post Link to post
Attila Kovacs 629 Posted June 1, 2023 do you want to still support VER_PLATFORM_WIN32_NT ? Share this post Link to post
Uwe Raabe 2057 Posted June 1, 2023 @Attila Kovacs All Windows versions from Windows NT up to the current have Win32Platform = VER_PLATFORM_WIN32_NT. Other possible values are Win32s and Windows 95. 1 Share this post Link to post
Fr0sT.Brutal 900 Posted June 1, 2023 (edited) Probably it' something to do with UTF16 surrogate pairs which are used in Far East languages Edited June 1, 2023 by Fr0sT.Brutal Share this post Link to post
DelphiUdIT 176 Posted June 1, 2023 FarEast is always true on Delphi x Windows: 1 Share this post Link to post
Remy Lebeau 1394 Posted June 1, 2023 (edited) 5 hours ago, David Heffernan said: I came across this code in the RTL: ... I'm wanting to call RegQueryInfoKey and wondering if I also need to mimic this far east if statement. No. It is a remnant from Delphi's pre-Unicode days (going all the way back to Delphi 5, if not earlier). Even then, I question why it was ever added in the first place, since the API always returned the correct sizes to begin with. So, this will cause the caller to unnecessarily waste memory (if they enumerate subkey/value names afterwards) and should be taken out. Quote Is it possible that this code is bogus? Yes. The increment is not necessary. I have filed a bug report: RSP-41787: TRegistry.GetKeyInfo() doubles size of MaxSubKeyLen and MaxValueLen Edited June 1, 2023 by Remy Lebeau 4 Share this post Link to post