本文介绍了RegEnumValue和REG_MULTI_SZ类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN说,有关RegEnumValue得到了

字符串数据

Suppose a value is REG_MULTI_SZ, does this mean that each of the strings in the sequence can or cannot be null-terminated, or just that only last double null terminator may be absent, but all inner null terminators are present?

解决方案

The strings in the sequence must be null terminated or else it would be impossible to determine where one of the string ends and the next string begins. From Registry Value Types describing REG_MULTI_SZ:

A sequence of null-terminated strings, terminated by an empty string (\0).
The following is an example:

    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.

The documentation is vague but my interpretation is that the last null terminators may be missing:

String1\0String2\0String3\0LastString

and code reading the value must ensure they are present for subsequent string extraction.

If the buffer being used to contain the value is large enough, including space for the terminating null characters, as long as the code ensures the trailing nulls are present there is nothing to be concerned about.

这篇关于RegEnumValue和REG_MULTI_SZ类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:48