Back to the WFC main page
CVolume
$Revision: 5 $
Description
This class makes it easy to handle volumes.
Data Members
None.
Methods
BOOL AutomaticallyEject( void )
-
Ejects the volume if it is not in use.
BOOL Close( void )
-
Closes the handle to the volume.
BOOL Dismount( void )
-
Dismounts the volume.
BOOL Eject( void )
-
OK, here's something useful. This method will call the
other methods in the correct order and have the media
spit out of the computer.
HANDLE GetHandle( void ) const
-
Gives you the handle to the volume so you can call the
Win32 API yourself.
BOOL GetType( UINT& drive_type )
-
Tells you what type of volume you've opened. It will return
one of the following (found in
winioctl.h
):
DRIVE_UNKNOWN
- The drive type cannot be determined.
DRIVE_NO_ROOT_DIR
- The root directory does not exist.
DRIVE_REMOVABLE
- The disk can be removed from the drive.
DRIVE_FIXED
- The disk cannot be removed from the drive.
DRIVE_REMOTE
- The disk is a remote (networked) drive.
DRIVE_CDROM
- The drive is a CD-ROM.
DRIVE_RAMDISK
- The drive is a RAM disk.
BOOL Load( void )
-
Loads the volume.
BOOL Lock( void )
-
Locks the volume.
BOOL Open( TCHAR drive_letter )
-
Opens a handle to the drive containing the volume.
BOOL PreventRemoval( BOOL prevent_removal = TRUE )
-
Tells NT whether or not you want to prevent the removal
of the volume.
BOOL Unlock( void )
-
Unlocks the volume.
Example
#include <wfc.h>
#pragma hdrstop
void eject_zip_cartridge( TCHAR zip_drive_letter )
{
WFCTRACEINIT( TEXT( "eject_zip_cartridge()" ) );
CVolume zip_volume;
if ( zip_volume.Open( zip_drive_letter ) != FALSE )
{
zip_volume.Eject();
}
}
API's Used
- CreateFile
- DeviceIoControl
- GetDriveType
- GetLastError
- Sleep
- ZeroMemory
Copyright, 2000, Samuel R. Blackburn
$Workfile: CVolume.cpp $
$Modtime: 1/17/00 9:25a $