xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DiskChange()

Changes the current disk drive.

Syntax

DiskChange( <cDrive> ) --> lSuccess

Arguments

<cDrive>
This is a single character (A-Z) specifying the disk drive to select as current drive.

Return

The funtion returns .T. (true) if the drive <cDrive> is selected as current drive, otherwise .F. (false) is returned.

Description

The function attempts to change the current disk drive and returns .T. (true) when the operation is successful.

Note:  DiskChange() uses operating system functionalities. If a disk drive exists but has no disk inserted, the operating system prompts the user for inserting a disk.

To suppress this behavior, call SetErrorMode() and pass 1 to it.

Info

See also:CurDrive(), CurDir(), DirChange(), DiskSpace(), IsDisk(), SetErrorMode()
Category: Directory functions , File functions , xHarbour extensions
Source:rtl\dirdrive.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates basic usage of DiskChange() and
// includes a user defined function that queries disk drives.

    PROCEDURE Main
       LOCAL aDisk, cDisk

       ? CurDrive()                    // result: C
       ? CurDir()                      // result: xhb\tests

       ? DiskChange( "D" )             // result: .T.

       ? CurDrive()                    // result: D
       ? CurDir()                      // result: apps\data

       ? DiskChange( "K")              // result: .F.

       ? CurDrive()                    // result: D
       ? CurDir()                      // result: apps\data

       aDisk := GetDrives()

       FOR EACH cDisk IN aDisk
          ? cDisk
       END
   RETURN

   FUNCTION GetDrives()
      LOCAL cDrive  := CurDrive()
      LOCAL aDrives := {}
      LOCAL nDrive  := 1

      FOR nDrive := 1 TO 26
         IF DiskChange( Chr( 64 + nDrive ) )
            AAdd( aDrives, Chr( 64 + nDrive ) )
         ENDIF
      NEXT

      DiskChange( cDrive )
   RETURN aDrives

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe