[英]Programmatically assign new letter to existing drive with C++
A trivial and easy way to do this would be to just shell out to diskpart
: 执行此操作的一个简单而容易的方法是将shell发送到diskpart
:
int main () {
int i = system("diskpart ..."); // Add args here.
cout << "command exited with code: " << i;
// ...
}
It has an /s
parameter that you can use to supply a script to run inside diskpart
, so you can simply write a text file out with the relevant subcommands and pass that into diskpart
with your system(...)
call. 它有一个/s
参数,可用于提供在diskpart
内运行的脚本,因此您只需使用相关子命令编写一个文本文件,并通过system(...)
调用将其传递给diskpart
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.