码迷,mamicode.com
首页 > Windows程序 > 详细

WPF WMI

时间:2017-05-26 16:00:24      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:ifile   sdi   sys   write   form   gic   rect   new   disk   

Add Reference:System.Management;

using System.Management;

 

private string CheckDisk()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * From Win32_LogicalDisk");
string sDisc = ""; //盘符
double dCurSize = 0.0;

//test
// string sCurPath = "";
// sCurPath = System.Environment.CurrentDirectory;
// var ini = new IniFile(sCurPath + "\\debug.ini");
// int i = 0;

foreach (ManagementObject mo in searcher.Get())
{
string disc = mo["Name"].ToString().Trim();
string size = mo["Size"].ToString().Trim();
string DriveType = mo["DriveType"].ToString().Trim();

if(string.Compare(DriveType,"3") == 0)
{
double dSize = Convert.ToDouble(size);
if (dSize > dCurSize) //string.Compare(size, sSize) > 0
{
sDisc = disc;
dCurSize = dSize;

// string sCurDisc = String.Format("CurDisc{0}", i);
// ini.IniWritevalue("SYSTEM", sCurDisc, sDisc);
}
}
// i++;
}
return sDisc;
}
catch
{
return "";
}
}

WPF WMI

标签:ifile   sdi   sys   write   form   gic   rect   new   disk   

原文地址:http://www.cnblogs.com/waterair/p/6908643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!