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

今天在尝试用_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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值