4.6 Deleting a Volume

The following diagram shows how the IVolumeClient interfaces are used to delete a volume.

Steps to delete a volume on a disk by using the IVolumeClient interfaces

Figure 6: Steps to delete a volume on a disk by using the IVolumeClient interfaces

  1. The client calls IVolumeClient::Initialize and passes its implementation of the IDMNotify Interface to the server.

  2. The client calls IVolumeClient::EnumVolumes to get the list of volumes from the server.

  3. For each volume, a VOLUME_INFO structure is returned. The server allocates the memory and returns the array of VOLUME_INFO structures and HRESULT to the client.

  4. The client verifies that the call was successful by looking at the returned HRESULT. If the call was successful, the client finds the volume to be deleted (for example, by looking at the id field in the VOLUME_INFO structure). Once the client finds the volume to be deleted, it calls IVolumeClient::DeleteVolume to delete the volume. The input parameter to DeleteVolume is the volume's LdmObjectId, which is the first member of the VOLUME_INFO structure. The client sets the force parameter to TRUE if it wants to force the deletion of the partition; otherwise, it sets the force parameter to FALSE. The client sets the volumeLastKnownState parameter from the VOLUME_INFO structure.

  5. The server deletes the volume and fills in the TASK_INFO structure. The call to IVolumeClient::DeleteVolume returns this TASK_INFO structure.

  6. The client verifies that the volume was successfully deleted by looking at the HRESULT returned from the call. The returned TASK_INFO structure will contain the deleted volume's id in the storageId field. The status field in the TASK_INFO structure will be REQ_COMPLETED.

  7. The server calls back the client with a disk modified notification on the IDMNotify interface's ObjectsChanged method.

  8. The client code processes the disk modified notification. For example, the client might query for the current disk information and all disk regions when it gets a disk modified notification, so that it can update its cache or display.

  9. The server calls back the client with a volume deleted notification on the IDMNotify interface's ObjectsChanged method.

  10. The client code processes the volume deleted notification. For example, the client might query for all volumes when it gets a volume deleted notification, so that it can update its cache or display.