Win32 API的P-Invoke来使磁盘联机,脱机,并设置独特的ID [英] Win32 API P-Invoke to bring a disk online, offline, and set unique ID
问题描述
我目前使用Diskpart的完成这些功能,但我想能够使用P-调用,而不必掏出一个外部进程在我的C#应用程序。
I am currently using Diskpart to accomplish these functions, but i would like to be able to use P-Invoke and not have to shell out to an external process in my C# app.
该示例Diskpart脚本是:
The example Diskpart scripts are:
//Online a disk
Select disk 7
disk online
// Reset GPT Identifier
select disk 7
UNIQUEID DISK ID=baf784e7-6bbd-4cfb-aaac-e86c96e166ee
我试图寻找pinvoke.net但只能找到与卷,没有磁盘处理功能。如何实现使用的PInvoke这些DISKPART命令任何想法
I tried searching pinvoke.net but could only find functions that dealt with volumes, not disks. Any idea on how to accomplish these diskpart commands using Pinvoke?
推荐答案
怎么样的 DeviceIoControl的 API?
如果不行,我会考虑使用WMI。特别是,看一看的WMI WIN32_DiskDrive 或的Win32_LogicalDisk 类。
If not, I would look into using WMI. In particular, take a look at the WMI WIN32_DiskDrive or WIN32_LogicalDisk classes.
这篇关于Win32 API的P-Invoke来使磁盘联机,脱机,并设置独特的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!