This seems to go a little beyond the file system so I thought I would try here. I am formatting a mounted disk to be blank, wiping out the MBR, GPT, everything. The following sequence doesn’t work right:
FSCTL_LOCK_VOLUME
…reformat…
FSCTL_DISMOUNT_VOLUME
FSCTL_UNLOCK_VOLUME
After the above procedure, NTFS does take some notice, but unfortunately the drive letter remains and accessing it gets an obscure message about the disk being corrupt. Disk management doesn’t notice anything changed unless manually pressing the refresh button. What I want is the functionality of the refresh button in disk management. That gets everything to notice the new contents from the ground up and then the old drive letter disappears. Is there a way to do this? Either kernel mode or user mode is ok.