views:

283

answers:

1

I would like to write a small utility/class library in C# that can enumerate the primary partitions on the disk associated with volume C on Windows 7. I would like to modify the active flag for any one the primary partitions on that disk. I would like to "consume" this library from managed code (C#). As I understand it, I will need to use the Virtual Disk Service described in ht tp://msdn.microsoft.com/en-us/library/bb986750(v=VS.85).aspx.

There seems to be something like a "primary interop assembly" for this API for Windows 2008: Windows.Storage.Vds.dll (see ht tp://blogs.msdn.com/taylorb/archive/2008/09/19/using-the-virtual-disk-service-vds-from-powershell-to-mount-and-use-vhd-s.aspx). I can't find this for Windows 7. Does it exist? If so, how do I obtain it? I can't find it, so I guess it's not publically available.

The next step would be to generate this code using tlbimp, but VDS doesn't export a type library. Is this true? I can't find it.

That leaves doing the COM stuff "by hand" either in C++ directly, along the lines of the examples above. These examples work, but are virtually inscrutable. Likewise I could create the client assembly by hand from the midl using techniques described in ht tp://msdn.microsoft.com/en-us/library/aa645736(VS.71).aspx. But I don't enough COM/COM Interop/VDS to do this in a reasonable way.

It strikes me the VDS dcom client api is virtual unusable and therefore everyone ends up scripting diskpart.exe. Surely I'm wrong about this.

Thanks.

+1  A: 

See this SO entry for some information to start with.

Laurent Etiemble