[Lazarus] Windows Registry, how do I read data from rdExpandString

Bo Berglund bo.berglund at gmail.com
Tue Feb 6 11:15:25 CET 2018


On Tue, 06 Feb 2018 10:58:21 +0100, Bo Berglund via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>What I want to know is how to treat data of the type REG_EXPAND_SZ in
>the registry when reading it. There are not that many such but for
>completeness I want to be able to display these kinds of data too.

If I use Reg.ReadString method on a REG_EXPAND_SZ item which I have
found in the user settings in the registry for CVSNT I get back a
string looking like this:
C:\Programs\cvsnt\cvsnt-default.pem

But if I export the registry key with RegEdit I get this instead:
"CertificateFile"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,\

6d,00,73,00,5c,00,63,00,76,00,73,00,6e,00,74,00,5c,00,63,00,76,00,73,00,6e,\

00,74,00,2d,00,64,00,65,00,66,00,61,00,75,00,6c,00,74,00,2e,00,70,00,65,00,\
  6d,00,00,00

It looks like the data is encoded with 16 bit values per character and
stored in successive 1-byte hex values with lsb first, but is this
always the case and why does the ReadString function not deliver the
hex in that case.

Can someone explain how it works? And why there is no TRegistry class
method for fetching the REG_EXPAND_SZ data type?
Does it have something to do with Unicode on Windows (I am testing on
a Windows 7 Pro X64 machine)?


-- 
Bo Berglund
Developer in Sweden



More information about the Lazarus mailing list