If there is a broken VHD chain (for example the parent VHD was modified, that's why the child no longer mounts), there's a way to fix it by using Hyper-V "Reconnect" feature. How do I do the same programmatically?
OK found a solution. One needs to open the VHD with OpenVirtualDisk
using OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS
flag. Then call SetVirtualDiskInformation
with SET_VIRTUAL_DISK_INFO_PARENT_PATH
passing the same path as it had before. This will update the parent unique ID and allow to mount the chain.