3.4.5.2.24.4 IVdsAdvancedDisk::DeletePartition (Opnum 6)

The DeletePartition method deletes a partition from the disk at a specified byte offset.

 HRESULT DeletePartition(
   [in] ULONGLONG ullOffset,
   [in] long bForce,
   [in] long bForceProtected
 );

ullOffset: The byte offset of the partition, from the beginning of the disk. This offset MUST be the offset at the start of a partition.

bForce: A Boolean that determines whether the partition deletion is forced. If this parameter is set to a nonzero value, calls to lock and dismount any file system on the partition that fail are ignored. If this parameter is set to zero and any file systems on the partition failed to be locked or dismounted, the server returns VDS_E_DEVICE_IN_USE.

bForceProtected: A Boolean value that determines whether deletion of a protected partition  will be forced.<95>

Return Values: The method MUST return zero or a non-error HRESULT (as specified in [MS-ERREF]) to indicate success, or return an implementation-specific nonzero error code to indicate failure. For the HRESULT values predefined by the Virtual Disk Service Remote Protocol, see section 2.2.3.

Note Creating or deleting partitions on dynamic disks is not supported.

Note This method is not valid for CD/DVD or super floppy devices. These devices do not support partition tables.

ERROR_SUCCESS (0x00000000)

When the server receives this message, it MUST perform the following:

  • Attempt to get exclusive access to the partition. If the server fails to get exclusive access to the partition, and the bForce parameter is not set to a non-zero value, then the server MUST return VDS_E_DEVICE_IN_USE.

  • Delete the partition following the parameters specified to the method.

  • If deleting the partition removed a volume, remove the corresponding volume object from the list of storage management objects. For each callback object that is registered in the list of callback objects, call the callback object's IVdsAdviseSink::OnNotify method by using a VDS_NOTIFICATION structure that has the following attributes:

    • objectType member is VDS_NTT_VOLUME.

    • Volume member is a VDS_VOLUME_NOTIFICATION that has the following attributes:

      • ulEvent is VDS_NF_VOLUME_DEPART.

      • volumeId is the VDS_OBJECT_ID of the volume object that was removed.

      • plexId is NULL GUID, but it is not relevant when ulEvent is VDS_NF_VOLUME_DEPART.

      • ulPercentCompleted range is 0-100 and is implementation specific; however, it is not relevant when ulEvent is VDS_NF_VOLUME_DEPART.

  • For each callback object that is registered in the list of callback objects, call the callback object's IVdsAdviseSink::OnNotify method by using a VDS_NOTIFICATION structure that has the following attributes:

    • objectType member is VDS_NTT_PARTITION.

    • Partition member is a VDS_PARTITION_NOTIFICATION that has the following attributes:

      • ulEvent is VDS_NF_PARTITION_DEPART.

      • diskId is the VDS_OBJECT_ID of the disk object corresponding to the disk from which the partition was deleted.

      • ullOffset is the byte offset at which the partition started on the disk.

  • For each callback object that is registered in the list of callback objects, call the callback object's IVdsAdviseSink::OnNotify method by using a VDS_NOTIFICATION structure that has the following attributes:

    • objectType member is VDS_NTT_DISK.

    • Disk member is a VDS_DISK_NOTIFICATION that has the following attributes:

      • ulEvent is VDS_NF_DISK_MODIFY.

      • diskId is the VDS_OBJECT_ID of this disk object.

  • Return an HRESULT indicating failure or success.