How to extend a volume programmatically

Viewed 815

My requirement is to extend drive volume through program. When I used IOCTL_DISK_GROW_PARTITION in DeviceIO to extend it, the disk management shows the new modified size while the size of the drive in This PC (My Computer) remains unchanged.

   BOOL DeviceIoControl(
      (HANDLE) hDevice,            // handle to device
      IOCTL_DISK_GROW_PARTITION,   // dwIoControlCode
      (LPVOID) lpInBuffer,         // input buffer
      (DWORD) nInBufferSize,       // size of the input buffer
      NULL,                        // lpOutBuffer
      0,                           // nOutBufferSize 
      (LPDWORD) lpBytesReturned,   // number of bytes returned
      (LPOVERLAPPED) lpOverlapped  // OVERLAPPED structure
    );

Through some analysis I found that while using this API the MBR of the disk is modified but the cluster bitmap of drive is not changed. I want to know the correct way of using this DeviceIO to expand a volume or some other API to do the same process.

1 Answers
Related