Set Active Disk Partition from Managed Code (Or Get EasyBCD's Source)

carifio

New Member
This thread may be off topic or outside the scope of this forum.

I'm writing a larger application that (will) set a particular partition active.
It needs to generate the contents of a partition table for a disk and then
set one of them active based on certain criteria. The application is
written in C#, therefore it's managed code. It does something similar
to what diskpart.exe does on Windows 7, with a little bit more logic.

I've been trying to figure out how to get access to this information using
APIs. It looks like IoReadPartitionInformationEx and IoSetPartitionInformationEx are on right track, but they seem to be a part of Windows Device Framework and NOT accessible via managed code. But EasyBCD seems to implement what I want.

Can I obtain the EasyBCD source code? Is so, how? What's the license? Is it
"commercial use" friendly?

If that's the not kosher, I'm happy to write this myself. Must I really use the
Win DDK? If so, can I use it from managed code? Is there a tutorial?

Pl. advise. Thanks.
 
Hi carifio, welcome to NeoSmart Technologies.

EasyBCD is free but closed source. While you are correct and EasyBCD is written in C#, all the lowlevel components that are responsible for disk enumeration, modification, and management are written in C++ with the Windows DDK.

Freebie tips:
  1. You can accomplish what you need in standard Win32 without the DDK, therefore, you can pull it off via P/Invoke instead of reverting to C++ like we did. Personally, it doesn't make any difference to me whether I'm writing in C++ or C#, so I just took the path of least resistance and wrote C++ libraries and binaries to do all the lowlevel stuff.
  2. You can script diskpart to do what you need, without having to resort any P/Invoke.

Hope this helps, post back and let me know if you found this of any use and how it goes :smile:
 
Back
Top