Search code examples
c++windowswinapivhd

convert partition to vhd windows API


I am trying to code a tool like disk2vhd. I'm using the VHD windows api:

Virtual Disk Functions

The Virtual Disk API In Windows 7

Demo various VHD API usage (CppVhdAPI)

I created a vhd file and created a partition in it, but I don't know how to convert a Windows partition to vhd like disk2vhd creates a vhd using CreateVirtualDisk().

I've tried to copy all items from that partition to my vhd but it does not work.

Please show me how to do that.


Solution

  • I think you should do the following:

    1. Load hard disk's information,
    2. load disk partition,
    3. create a file vhd,
    4. copy partition to vhd.