RegistryCStrEntryCreate creates a new child name entry in the Name Registry.
OSStatus RegistryCStrEntryCreate(
const RegEntryID *parentEntry,
const RegCStrPathName *name,
RegEntryID *newEntry);
Given the RegEntryID value of a parent name entry, RegistryCStrEntryCreate creates a new entry that is a descendant of the parent, with the C string pathname name. It returns the RegEntryID value that identifies the new name entry.
The rules for composing pathnames are given in Pathnames. Note that the pathname in name includes the name of the new entry. If parentEntry is NULL, name is a pathname relative to the root.
Listing 10-2 shows code that uses RegistryCStrEntryCreate to add a name entry for a new child device to the Name Registry.
Listing 10-2 Adding a name entry to the Name Registry
OSStatus
AddDevice(
constRegEntryID *parentEntry,
constRegCStrEntryName *deviceName,
RegEntryID *deviceEntry
)
{
RegCStrPathName devicePathBuf[kRegCStrMaxEntryNameLength+2]
= {kRegPathNameSeparator,kRegPathNameTerminator};
RegCStrPathName *devicePath = &devicePathBuf[0];
OSStatus err = noErr;
/*
* Need to construct a relative path name since we are not
* attaching the new entry to the root.
*/
devicePath = strcat(devicePath, deviceName);
err = RegistryCStrEntryCreate(parentEntry, devicePath, deviceEntry);
return err;
}