PATH 
ADC Home > Documentation > Hardware > Device Managers and Drivers > PCI Card Services > Designing PCI Cards and Drivers for Power Macintosh Computers


  

RegistryPropertyCreate

RegistryPropertyCreate adds a new property to a name entry.

OSStatus RegistryPropertyCreate (
                     const RegEntryID *entryID,
                     const RegPropertyName *propertyName,
                     const void *propertyValue,
                     RegPropertyValueSize propertySize);
--> entryID
Pointer to the RegEntryID value that identifies a name entry.
--> propertyName
Pointer to the name of the property to be created.
--> propertyValue
Pointer to the value to create for the new property.
--> propertySize
The size in bytes of the new property.
DESCRIPTION

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.

RESULT CODES
noErr 0 No error
paramErr -50 Bad parameter
nrNotEnoughMemoryErr -2537 Not enough space in the system heap
nrInvalidNodeErr -2538 RegEntryID value not valid
nrNotCreatedErr -2540 Entry or property could not be created
nrNameErr -2541 Name invalid, too long, or not terminated
CODE SAMPLE

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;
}

© 1999 Apple Computer, Inc. – (Last Updated 26 March 99)