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


  

RegistryEntryIterate

One kind of iteration call, RegistryEntryIterate, retrieves the next name entry in the Name Registry by moving in a specified direction.

OSStatus RegistryEntryIterate(
                     RegEntryIter *cookie,
                     RegEntryIterationOp relationship,
                     RegEntryID *foundEntry,
                     Boolean *done);
--> cookie
Pointer to the iterator used by iterate and search routines.
--> relationship
The iteration direction (values defined in Data Structures and Constants ).
<-- foundEntry
Pointer to the ID of the next name entry found.
<-- done
Pointer to the interation result. A value of true means iteration is completed.
DESCRIPTION

RegistryEntryIterate moves from entry to entry in the Name Registry, marking its position by changing the value of cookie. The direction of movement is indicated by relationship. RegistryEntryIterate returns the RegEntryID value that identifies the next name entry found in foundEntry, or true in done if all name entries have been found.

EXECUTION CONTEXT

RegistryEntryIterate may be called from any execution level.

RESULT CODES
noErr 0 No error
paramErr -50 Bad parameter
CODE SAMPLE

Listing 10-3 shows code using RegistryEntryIterate and RegistryEntryDelete that finds and removes all immediate child entries of a given parent entry. Deleting a name entry invalidates the iterator and RegEntryID for that name entry.

Listing 10-3 Finding and removing child entries

OSStatus
RemoveDevices(
    constRegEntryID        *parentEntry
)
{
    RegEntryID              entry;
    RegEntryIter            cookie;
    RegEntryIterationOp     iterOp;
    Boolean                 done;
    OSStatus                err = noErr;

    RegistryEntryIDInit(&entry);

    err = RegistryEntryIterateCreate(&cookie);
    if(err != noErr)
        return err;

    /* Reset iterator to point to the parent entry */
    err = RegistryEntryIterateSet(&cookie, parentEntry);

    if (err == noErr) {

        /* Include just immediate chidren, not all descendants */
        iterOp=kRegIterChildren;
        do {
            err=RegistryEntryIterate(&cookie, iterOp, &entry, &done);
            if (!done && err == noErr) {
                err = RegistryEntryDelete(&entry);
                RegistryEntryIDDispose(&entry);
            }
            iterOp = kRegIterChildren;

        } while (!done && err == noErr);
    }
    RegistryEntryIterateDispose(&cookie);
    returnerr;
}

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