RegistryCStrEntryLookup finds a name entry in the Name Registry by starting from a designated point and traversing a defined path. This makes it faster than most search or iterate routines.
OSStatus RegistryCStrEntryLookup(
const RegEntryID *searchPointID,
const RegCStrPathName *pathName,
RegEntryID *foundEntry);
RegistryCStrEntryLookup finds a name entry in the Registry based on pathName, starting from the entry designated by searchPointID.
If searchPointID is NULL, the path is assumed to be a rooted path and pathName must contain an absolute pathname. If the pathname begins with a colon, the path is relative to searchPointID and pathName must contain a relative pathname. If the pathname does not begin with a colon, the path is a rooted path and pathName must contain an absolute pathname.
After using RegistryCStrEntryLookup, dispose of the foundEntry ID by calling RegistryEntryIDDispose.
A reverse lookup mechanism has not been provided because some name services may not provide a fast, general algorithm. To perform reverse lookup, the process described in Name Iteration and Searching should be used.
noErr
|
0 | No error |
paramErr
|
-50 | Bad parameter |
nrInvalidNodeErr
|
-2538 | RegEntryID value not valid |
nrPathNotFound
|
-2539 | Path component lookup failed |
Listing 10-5 shows code that uses RegistryCStrEntryLookup to obtain the entry ID for a child device.
Listing 10-5 Obtaining an entry ID
OSStatus
LocateChildDevice(
constRegEntryID *parentEntry,
constRegCStrEntryName *deviceName,
RegEntryID *deviceEntry
)
{
RegCStrPathName devicePathBuf[kRegCStrMaxEntryNameLength+2]
= {kRegPathNameSeparator, kRegPathNameTerminator};
RegCStrPathName *devicePath = &devicePathBuf[0];
OSStatus err = noErr;
/*
* Need to construct a relative pathname from the parent entry.
*/
devicePath = strcat(devicePath,deviceName);
err = RegistryCStrEntryLookup(parentEntry, devicePath, deviceEntry);
return err;
}