Inheritance

You can specify data in the metabase to be inheritable, so that if you add a data entry to a key and specify it as inheritable, all of its subkeys can access that data. This is much more efficient than setting the same data for each key in the metabase. For example, if you add the inheritable data MD_MYDATA for the key /LM, the subkeys /LM/W3SVC and /LM/MSFTPSVC can also return MD_MYDATA; their subkeys can also return MD_MYDATA. However, if a subkey already has the same metabase identifier set, the inheritable data is not applied to it, nor to its subkeys. Inheritance cannot skip keys—keys inherit data from the nearest parent key where the identifier is set.

You can specify that an entry is inheritable by setting the METADATA_INHERIT flag in the dwMDAttributes member of the METADATA_RECORD structure that is passed to the SetData method.

When retrieving data, you can specify that inherited data be returned by setting the METADATA_INHERIT flag in the dwMDAttributes member of the METADATA_RECORD structure that is passed to the GetData or EnumData method. For the GetAllData method, you must specify this flag in the dwMDAttributes parameter. If the METADATA_INHERIT flag is not set, inherited data is not returned.

You can use the METADATA_PARTIAL_PATH flag to specify that inherited data be returned, even if a requested path does not exist. If you add the same inheritable data at the key /LM as in the preceding example, a subkey /LM/MySvc would return the inheritable data, MD_MYDATA, regardless of whether that key actually exists in the metabase. The METADATA_PARTIAL_PATH flag applies only if the METADATA_INHERIT flag is also set.

You can use the METADATA_PARTIAL_PATH flag to minimize the number of keys you create in the metabase. For example, if files in a directory have no metabase data of their own, you can specify data as inheritable at the directory key and use the METADATA_PARTIAL_PATH flag to return inherited data for individual files without having to create keys for them.

You can use the METADATA_ISINHERITED flag to determine if retrieved data is local or inherited. If specified on a call to any method that retrieves data, the method will return METADATA_ISINHERITED for inherited data elements.

For more information on inheritance see Property Inheritance.