Share this page

# getdrive

File Manipulation Functions

Returns the name of the current drive. Windows only.

    int getdrive( void);

The getdrive function returns an integer representing the drive letter: 1 = A, 2 = B, etc.

## Return Values

This function returns an integer upon success and (-1) for failure.

## Example

The following example uses getdrive to save the current place in the file system, before moving to all other available drives. It finally returns to the original drive.

Copy code

        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:

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: