我想用 C# 编写一个小型实用程序/类库,它可以枚举与 Windows 7 上的 C 卷关联的磁盘上的主分区。我想修改该磁盘上任何一个主分区的活动标志。我想从托管代码(C#)“使用”这个库。据我了解,我需要使用 http://msdn.microsoft.com/en-us/library/bb986750(v=VS.85).aspx。
Windows 2008 的此 API 似乎有一个类似“主要互操作程序集”的东西:Windows.Storage.Vds.dll(请参阅 http://blogs.msdn.com/ taylorb/archive/2008/09/19/using-the-virtual-disk-service-vds-from-powershell-to-mount-and-use-vhd-s.aspx)。我找不到适用于 Windows 7 的此程序。它存在吗?如果是的话,我该如何获得它?我找不到它,所以我猜它不是公开的。
下一步是使用 tlbimp生成此代码,但 VDS 不导出类型库。这是真的吗?我找不到它。
这就使得 COM 的工作要么直接在 C++ 中“手工”完成,就像上面的例子一样。这些例子虽然有效,但实际上却难以理解。同样,我可以使用 http://msdn.microsoft.com/en-us/library/aa645736(VS.71).aspx。但我没有足够的 COM/COM Interop/VDS 来以合理的方式做到这一点。
令我震惊的是,VDS dcom 客户端 api 几乎无法使用,因此每个人最终都编写了 diskpart.exe 脚本。这件事我肯定是错的。
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 http://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 http://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 publicly 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 http://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.
发布评论