How to attain drive letter or assign drive letter to a volume

Discussion in 'Windows Vista Drivers' started by Cravin Zheng, Oct 11, 2008.

  1. Cravin Zheng

    Cravin Zheng Guest

    I'm working on a Delphi program which needs to attain and change the drive
    letters. I tried to call 'DiskPart' command and it's script to achieve this
    function. However, 'DiskPart' is not so stable. Is there any better method
    instead? Like Windows API or other SDK.

    Thank you very much.

    Best Regards,

    Cravin Zheng
     
    Cravin Zheng, Oct 11, 2008
    #1
    1. Advertisements

  2. These Win32 functions seem related: SetVolumeMountPoint,
    DeleteVolumeMountPoint, QueryDosDevice, and DefineDosDevice.
    I think the effects of the last one do not persist past reboots.
    There is an "Editing Drive Letter Assignments" example in MSDN.
     
    Kalle Olavi Niemitalo, Oct 11, 2008
    #2
    1. Advertisements

  3. Cravin Zheng

    Cravin Zheng Guest

    Dear Kalle,

    Thanks a lot.

    Cravin Zheng

     
    Cravin Zheng, Oct 11, 2008
    #3
  4. DefineDosDevice is the way.
     
    Maxim S. Shatskih, Oct 14, 2008
    #4
  5. These Win32 functions seem related: SetVolumeMountPoint,
    Correct, thanks for correcting me.

    "Volumes" are the subkind of the drive-letter-assignable entities. You can
    enumerate the volumes using FindFirstVolume, you can get their on-disk
    "coordinates" by
    CreateFile/DeviceIoControl/IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, and then,
    if you want to assign the drive letter to the volume, please use
    SetVolumeMountPoint.

    This also works for removable media devices like CD/DVD/BD drives.

    DefineDosDevice should only be used for some virtual software-only emulated
    disks or so where the kernel mode code lacks the "volume" capability. Yes,
    DefineDosDevice is not persistent.
     
    Maxim S. Shatskih, Oct 14, 2008
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.