实现效果:

知识运用:
API函数SHFormatDrive //用于格式化磁盘

实现代码:
[DllImport("shell32.dll")]
private static extern int SHFormatDrive(IntPtr hWnd,int drive,long fmtID,int Options);
private const long SHFMT_ID_DEFAULT = 0xFFFF;
private void button1_Click(object sender, EventArgs e)
{
try
{
SHFormatDrive(this.Handle,this.comboBox1.SelectedIndex,SHFMT_ID_DEFAULT,0);
MessageBox.Show("格式化完成","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch (Exception)
{
MessageBox.Show("格式化失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
浙公网安备 33010602011771号