开发者

will registry key take default value upon setting invalid value

I am setting a registry key with invalid value (setting a REG_DWORD key value with a REG_SZ). Will registry hold the value which it was having it before or will it reset it to its default value?

For example. I have set REG_DWORD key and have set it to value '4'. Default value of this key is '2'. Now when i try to set this key with api 'RegSetValueEx(...)' with an invalid REG_SZ value. Set was success. Now if i get this key value, will that be a default val开发者_JS百科ue '2' or will it be previous set value '4'??


RegSetValueEx Sets the data and type of a specified value under a registry key.

It will just change the type of the stored value to REG_SZ and set the value you specified, it doesn't check what value or type there were before. So when you read the value you'll get the last value you set there. There's no such thing as 'invalid' REG_SZ.

Also forget about 'default value for the key'. It's not what you think it is. This is not the value that the API will return if something fails, it's just a fancy name for an anonymous value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜