I just found that the REG_OPTION_VOLATILE of create_key in hkcr may have some tricks. Not surprisingly found a strange situation when testing on windows. See my test here please : http://newtestbot.winehq.org/JobDetails.pl?Key=932 This happens as following : First create hkcu/software/classes/key1, then create the hkcr/key1/subkey with REG_OPTION_VOLATILE. RegEnumKey on hkcr will give two 'key1'. I tried to use RegQueryInfoKeyA to count them, also there are more than there should be. Why there are two duplicated keys? May it be a bug of windows? If it is, should we design our algorithm to avoid or treat it as a normal feature?