CBDisk Class
Properties Methods Events Configuration Settings Errors
The CBDisk class lets applications create a virtual disk backed by a contiguous block of data.
Syntax
cbfsdisk.Cbdisk
Remarks
The CBDisk class is used to create a virtual disk whose contents are stored in one contiguous block of data. CBDisk doesn't implement any filesystem functionality, nor does it attempt to process virtual disks' contents in any way; its minimal API is focused wholly on the efficient transfer of raw disk data.
Therefore, a CBDisk-based application's only responsibility is to maintain a finite block of data for each virtual disk, reading from and writing to it as instructed by the class. This block of data functions as a virtual disk's storage space, and it can be located anywhere the application desires.
Newly-created virtual disks begin in a raw state, and must be formatted with a known filesystem (e.g., NTFS, FAT32, exFAT, etc.) using standard Windows formatting utilities. Once a virtual disk has been formatted, it can be used just like any other storage device. When the application is finished with a virtual disk, the block of data associated with it can be saved so that the virtual disk can be "re-created" at a later time.
Getting Started
Each CBDisk class instance controls a single virtual disk. Applications can use multiple instances of the CBDisk class if their use-case requires the creation of multiple virtual disks. The class's Tag property can be used to distinguish between instances during event handlers by storing some disk-specific information ("disk context") or UID.
Here's how to get up and running:
- If the system driver hasn't been installed yet, call the Install method to do so. This only needs to be done once.
- In production, the system driver can be installed (or updated) ahead-of-time by the application's installation script using the Installer DLL. Please refer to the Driver Installation topic for more information.
- Call the Initialize method to initialize the CBDisk class. This must be done each time the application starts (if the application is using multiple CBDisk class instances, only the first instance created should be used to call Initialize).
- Ensure that the class's event handlers have been implemented so that the driver can read and write raw disk data. Please refer to the events' documentation for more information.
- Create a virtual disk by calling the CreateStorage method.
- Create one or more Mounting Points for the virtual disk using the AddMountingPoint method. A mounting point can be a drive letter, a UNC path, or a directory on an existing NTFS-formatted drive.
- Call the MountMedia method to "insert storage media" into the virtual disk drive. (This "media" can be changed at any time later using the UnmountMedia and MountMedia methods.)
- Later, the application can unmount the "media" from the virtual disk using the UnmountMedia method. At this point, the application could call the MountMedia method again to "insert different storage media".
- To delete the virtual disk entirely, call the DeleteStorage method.
- To uninstall the system driver, call the Uninstall method. This should not be done as part of the driver upgrade process.
- In production, the system driver can be uninstalled by the application's uninstallation script using the Installer DLL. Please refer to the Driver Installation topic for more information.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
Active | Whether the class is active and handling OS requests. |
MountingPoints | Collection of mounting points for the virtual disk. |
ReadOnly | Whether the virtual disk should be mounted in read-only mode. |
StorageCharacteristics | The characteristic flags to create the virtual disk with. |
StorageGUID | The GUID to create the virtual disk with. |
StoragePresent | Whether a virtual disk has been created. |
StorageType | The type of virtual disk to create. |
Tag | Stores application-defined data specific to this instance of the class. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
AddMountingPoint | Adds a mounting point for the virtual disk. |
Config | Sets or retrieves a configuration setting. |
CreateStorage | Creates the virtual disk. |
DeleteStorage | Deletes the virtual disk. |
GetDriverStatus | Retrieves the status of the system driver. |
GetModuleVersion | Retrieves the version of a given product module. |
Initialize | Initializes the class. |
Install | Installs (or upgrades) the product's system drivers and/or helper DLL. |
IsIconRegistered | Checks whether the specified icon is registered. |
MountMedia | Mounts media in the virtual disk, making it accessible for reading and writing. |
RegisterIcon | Registers an icon that can be displayed as an overlay on the virtual disk in Windows Explorer. |
RemoveMountingPoint | Removes a mounting point for the virtual disk. |
ResetIcon | Resets the virtual disk's icon back to default by deselecting the active overlay icon. |
SetIcon | Selects a registered overlay icon for display on the virtual disk in Windows Explorer. |
ShutdownSystem | Shuts down or reboots the operating system. |
Uninstall | Uninstalls the product's system drivers and/or helper DLL. |
UnmountMedia | Unmounts media from the virtual disk. |
UnregisterIcon | Unregisters an existing overlay icon. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
DiskRead | Fires when the OS needs to read data from the virtual disk. |
DiskWrite | Fires when the OS needs to write data to the virtual disk. |
Ejected | Fires when the media and virtual disk have been ejected. |
Error | Fires if an unhandled error occurs during an event. |
GetDiskSize | Fires when the OS needs to retrieve the size of the virtual disk. |
Configuration Settings
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
AsyncDeleteStorageNotifications | Whether system broadcasts for virtual disk deletion are sent asynchronously. |
DeviceChangeBroadcastsEnabled | Whether the user-mode API broadcasts WM_DEVICECHANGE messages. |
LoggingEnabled | Whether extended logging is enabled. |
SectorSize | The sector size to create the virtual drive with. |
SupportSearchIndexer | Specifies whether the driver must take additional measures to support indexing by Windows Search. |
BuildInfo | Information about the product's build. |
LicenseInfo | Information about the current license. |