Example: chdrive

The following example uses chdrive to move to all available drives on the file system. It saves the original drive in curdrive, so it can be restored later.

    int ch, drive, curdrive;

    static char path[1024];

    // Save current drive letter so it can be restored later

    curdrive = getdrive();

    // If we can switch to the drive, it exists

    lr_output_message ("Available drives are:");

    for (drive = 1; drive <= 26; drive++)

    if (!chdrive(drive))

        lr_output_message ("%c: ", drive + 'A' - 1);

        chdrive(curdrive); // Restore original drive

Example: Output:
Action.c(10): Available drives are:
Action.c(14): C:
Action.c(14): D:
Action.c(14): G:
Action.c(14): L:
Action.c(14): R:
Action.c(14): Z: