_winreg中SetValueEx和SetValue两个方法的区别

来源:互联网 发布:java telnet接口 编辑:程序博客网 时间:2024/05/22 07:58

今天在尝试用_winreg来改注册表的时候,发现用setValue不能顺利的改变, 但是用SetValueEx可以, 于是搜集了一下这两个方法的关系:

_winreg.SetValue(key, sub_key, type, value)¶

    Associates a value with a specified key.

    key is an already open key, or one of the predefined HKEY_* constants.

    sub_key is a string that names the subkey with which the value is associated.

    type is an integer that specifies the type of the data. Currently this must be REG_SZ, meaning only strings are supported. Use the SetValueEx() function for support for other data types.

    value is a string that specifies the new value.

    If the key specified by the sub_key parameter does not exist, the SetValue function creates it.

    Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the filenames stored in the configuration registry. This helps the registry perform efficiently.

    The key identified by the key parameter must have been opened with KEY_SET_VALUE access.

_winreg.SetValueEx(key, value_name, reserved, type, value)¶

    Stores data in the value field of an open registry key.

    key is an already open key, or one of the predefined HKEY_* constants.

    value_name is a string that names the subkey with which the value is associated.

    type is an integer that specifies the type of the data. See Value Types for the available types.

    reserved can be anything – zero is always passed to the API.

    value is a string that specifies the new value.

    This method can also set additional value and type information for the specified key. The key identified by the key parameter must have been opened with KEY_SET_VALUE access.

    To open the key, use the CreateKey() or OpenKey() methods.

    Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the filenames stored in the configuration registry. This helps the registry perform efficiently.

原创粉丝点击