首页 > 其他 > 详细

格式化磁盘

时间:2019-01-22 21:38:36      阅读:225      评论:0      收藏:0      [点我收藏+]

实现效果:

  技术分享图片

知识运用:

  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);
            }
        }

  

格式化磁盘

原文:https://www.cnblogs.com/feiyucha/p/10306031.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!