March 28, 2024, 06:12:07 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Understanding the registry - getting values

Started by Andy, August 27, 2017, 11:39:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

August 27, 2017, 11:39:41 PM Last Edit: August 28, 2017, 12:43:16 AM by Andy
Currently, I'm adding new functions into my registry.lib file and updating my registry viewer and editor programs - both of which I will release when finished.

While trying my new RegCopyKey function I found out several things:

A REG_SZ (a simple string entry) which I wrongly presumed to be a maximum length of 255 is only limited to the amount of available memory - and I found an example in Adobe's string entries - they were 564 characters.  So I've amended the RegGetValue function to read in a very long string.

A REG_EXPAND_SZ (an expandable string), typically used for variables in the registry, e.g. %USERNAME% has a null character at the end of the string, like this:

This is an expandable string\0 - so you need to use an ISTRING to work with this type of entry.

A REG_MULTI_SZ (a multi string entry) is one with several lines, each line ends with a null (\0), and the string also ends with an extra \0

Line 1\0this is line2\0this is the final line\0\0 (note the extra null at the end)
again you need to use an ISTRING to work with this type of entry.

What no one tells you is there are line feed characters added to the nulls, so the actual layout of a multi string is this:

Line 1\0 + chr$(10)+this is line2\0+ chr$(10)+final line\0+ chr$(10)+\0+ chr$(10)

A REG_BIN (binary value) is in my opinion the hardest to work with, when you read in a binary value, you need to convert it from it's Asc value to Hex bit by bit.

And writing back a value you have to convert Hex back to Asc bit by bit.
Again you need to use an ISTRING to work with this type of entry.

For Expandable strings, Multi strings and binary entries you need to specify the FULL length of the entry - this includes any NULL and/or Line feed characters - something that many people forget.

Most of this is documented by MS, but you may have to do a lot of digging to find it (or you might just get lucky first time).











Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.