#1 2019-12-12 17:51:02

Márcio Baroni
Member
From: Brasil
Registered: 2015-10-07
Posts: 28

Error on SynCommons.RetrieveSystemInfo

after commit enhanced RetrieveSystemInfo e.g. running from a VM I received a runtime 217

Error:

ERegistryException exception message  : Invalid data type for 'SystemBiosVersion'.

on then line 

prod := SysUtils.Trim(ReadString('SystemBiosVersion'));

The problem is that the key value is multi-line (REG_MULTI_SZ) and the readstring function can't read
this only happens if there is no "SystemProductName" key in the windows registry

Offline

#2 2019-12-12 20:17:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Error on SynCommons.RetrieveSystemInfo

Good point.

How do we read REG_MULTI_SZ ?

Offline

#3 2019-12-12 21:17:13

Márcio Baroni
Member
From: Brasil
Registered: 2015-10-07
Posts: 28

Re: Error on SynCommons.RetrieveSystemInfo

A possible fix:

var
  buffer: string;
  len: Cardinal;
      ...
      if OpenKeyReadOnly('\Hardware\Description\System') then begin
        if prod='' then begin
          len := GetDataSize('SystemBiosVersion'); //new
          SetLength(buffer, len); //new
          ReadBinaryData('SystemBiosVersion', Pointer(buffer)^, len); //new
          prod := UTF8ToString(Trim(StringReplaceAll(StringToUTF8(buffer), #0, ' '))); //new
        end;
        if prodver='' then begin
          prodver := SysUtils.Trim(ReadString('VideoBiosVersion'));
          i := Pos(#13,prodver);
          if i>0 then // e.g. multilines 'Oracle VM VirtualBox Version 5.2.33'
            SetLength(prodver,i-1);
        end;
      end;
      ....

Offline

#4 2019-12-13 23:07:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Error on SynCommons.RetrieveSystemInfo

Please check https://synopse.info/fossil/info/6a4eec4faf

It should work as expected now, thanks to the new TWinRegistry object, which is REG_MULTI_SZ ready.

Offline

#5 2019-12-15 17:41:21

Márcio Baroni
Member
From: Brasil
Registered: 2015-10-07
Posts: 28

Re: Error on SynCommons.RetrieveSystemInfo

ab, thanks for the fix but the fossil commit was not for github.
The SynCommons.pas file has not been updated on github.

Offline

#6 2019-12-16 08:11:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Error on SynCommons.RetrieveSystemInfo

Yes, I use rsynch to update the mORMot folder, and sometimes it doesn't synch...

Thanks for the update.

Offline

Board footer

Powered by FluxBB