开发者

Win32 API P-Invoke to bring a disk online, offline, and set unique ID

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 a开发者_如何转开发n external process in my C# app.

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

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?


I'm not sure exactly what Dispart does but I'd suggest looking at WMI which might have this kind of functionality. It's usually a good place to look when you need to do something less common in Windows.

There's the Storage WMI Classes which might have something useful:
http://msdn.microsoft.com/en-us/library/ff567016%28VS.85%29.aspx

Edit: removed the suggestions about Volumes since I had missed that you're not interested in that.


How about the DeviceIOControl API?

If not, I would look into using WMI. In particular, take a look at the WMI WIN32_DiskDrive or WIN32_LogicalDisk classes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜