RegistryCStrEntryToName retrieves the name component of a name entry and returns the ID of the entry's parent.
OSStatus RegistryCStrEntryToName (
const RegEntryID *entryID,
RegEntryID *parentEntry,
RegCStrEntryName *nameComponent,
Boolean *done);
Given a RegEntryID value that identifies a name entry, RegistryCStrEntryToName returns the RegEntryID value that identifies its parent entry in parentEntry and the name component of the name entry in nameComponent. RegistryCStrEntryToName is useful for locating the parent of a name entry and for constructing a relative pathname from the parent to the entry.
noErr
|
0 | No error |
paramErr
|
-50 | Bad parameter |
nrInvalidNodeErr
|
-2538 | RegEntryID value not valid |
Listing 10-6 shows code that uses RegistryCStrEntryToName to obtain the parent entry for a given child entry.
Listing 10-6 Obtaining a parent entry
OSStatus LocateParentDevice(
constRegEntryID *deviceEntry,
RegEntryID *parentEntry
)
{
RegCStrEntryName deviceNameBuf[kRegCStrMaxEntryNameLength + 1];
Boolean done;
OSStatus err = noErr;
err = RegistryCStrEntryToName(deviceEntry, parentEntry,
&deviceNameBuf[0], &done);
if (err != noErr)
return err;
/*
* If done == true, we have reached the root, there is no parent!
*/
if (done)
err = kNotFoundErr;
return err;
}