RegistryPropertyCreate adds a new property to a name entry.
OSStatus RegistryPropertyCreate (
const RegEntryID *entryID,
const RegPropertyName *propertyName,
const void *propertyValue,
RegPropertyValueSize propertySize);
Given a RegEntryID value that identifies a name entry, RegistryPropertyCreate adds a new property to that entry with name propertyName and value propertyValue. The entryID parameter may not be null.
The propertySize parameter must be set to the size (in bytes) of propertyValue.
Property names may be any alphanumeric strings but may not contain slash (/) or colon (:) characters.
In Listing 10-7, RegistryPropertyCreate, RegistryPropertyGetSize,and RegistryPropertySet are used to update the value of a given property of a name entry. If the property exists, its value is updated. If it doesn't exist, a new property is created.
Listing 10-7 Updating or creating a property
OSStatus UpdateDeviceProperty(
constRegEntryID *deviceEntry,
constRegPropertyName *propertyName,
constvoid *newPropertyValue,
constRegPropertyValueSize newPropertySize
)
{
RegPropertyValueSize PrevPropertySize;
OSStatus err = noErr;
/*
* RegistryPropertyGetSize used here to see if the property exists.
*/
err = RegistryPropertyGetSize(deviceEntry, propertyName, &PrevPropertySize);
if (err == noErr){
err = RegistryPropertySet(deviceEntry, propertyName,
newPropertyValue, newPropertySize);
return err;
} else if (err == nrNotFoundErr)
err = RegistryPropertyCreate(deviceEntry, propertyName,
newPropertyValue, newPropertySize);
return err;
}