LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't read registry value (type REG_MULTI_SZ)

Hi,
I tried to read a registry value of the type REG_MULTI_SZ (multilined Strings) with CVI8.1
 
#define REG_STR_BIOSPATH    "HARDWARE\\DESCRIPTION\\System"
#define REG_VALUE_BIOSVERSION   "SystemBiosVersion"
.
..
rc = RegReadString (REGKEY_HKLM, REG_STR_BIOSPATH, REG_VALUE_BIOSVERSION, regStr, sizeof(regStr), &lenRegStr);
 
Getting always error code -5069 (= Icorrect type for registry value). So it seems to me that its not possible to read that kind of regestry value.
So is there a trick? Or does anybody have an idea?
 
Peter
 
0 Kudos
Message 1 of 4
(4,454 Views)
You might try reading it with the Win32 SDK call rather than going through the NI routine.  Sounds like the NI routine doesn't support the REG_MULTI_SZ type.

I tend to use the Win32 calls - there's overhead to learning all the weirdness, but then ultimately it will always work as opposed to running into an NI implementation issue.

Menchar
0 Kudos
Message 2 of 4
(4,441 Views)
Hi Peter,

You could use the RegEnumerateValue function in the toolbox like such:

status = RegEnumerateValue (REGKEY_HKLM, "HARDWARE\\DESCRIPTION\\System", 4, valueName, &valueLength, dataBuffer, &dataLength, &valueType);

I hard-coded the index of the value to be retrieved in this case to 4 (which refers to the SystemBiosVersion key). However, you probably would want to call RegQueryInfoOnKey before that to get some information about the total number of keys available and then do some parsing. There is a code-snippet of this in the help for RegEnumerateValue.

You would also need to set the valueLength and dataLength values to a number as well before calling this function.

After calling this function, you should get back the appropriate information in the dataBuffer variable (use the Memory display for that variable to see the contents). However, you will then need to parse through that variables memory and get out whatever information you want. You need to do this because the REG_MULTI_SZ types are a sequence of null-terminated strings, terminated by an empty string (\0).  For example, you would have something like:

String1\0String2\0String3\0LastString\0\0

The first \0 terminates the first string, the second to the last \0 terminates the last string, and the final \0 terminates the sequence. Note that the final terminator must be factored into the length of the string. 

Hope this helps!

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 3 of 4
(4,435 Views)

Thank you for that response, it worked for me.

0 Kudos
Message 4 of 4
(1,708 Views)