using System;
using Microsoft.Win32;
using System.Globalization;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Text;
using System.IO;
namespace HKH.Common
{
/// <summary>
/// Summary description for clsIDE.
/// </summary>
public class clsIDE
{
/// <summary>
/// 擷取硬碟相應分區的序號
/// </summary>
/// <returns></returns>
public static string GetAllSerialNumber()
{
string Dri = "";
System.Management.ManagementClass mo = new System.Management.ManagementClass("Win32_LogicalDisk");
System.Management.ManagementObjectCollection mc = mo.GetInstances();
foreach (System.Management.ManagementObject m in mc)
{
if (Convert.ToString(m.Properties["DriveType"].Value) == "3")
{
Dri = Dri + m.Properties["VolumeSerialNumber"].Value.ToString() + "/n";
}
}
Dri = Dri.Substring(0, Dri.Length - 1);
return Dri;
}
/// <summary>
/// 擷取硬碟相應分區的序號
/// </summary>
/// <param name="Drive">盤符(如 C)</param>
/// <returns></returns>
public static string GetSpecialVolumeSerialNumber(string Drive)
{
string Dri = "";
System.Management.ManagementClass mo = new System.Management.ManagementClass("Win32_LogicalDisk");
System.Management.ManagementObjectCollection mc = mo.GetInstances();
foreach (System.Management.ManagementObject m in mc)
{
if (Convert.ToString(m.Properties["DriveType"].Value) == "3")
{
if (m.Properties["Name"].Value.ToString().ToUpper().Trim().Substring(0, 1) == Drive.ToUpper().Trim())
{
Dri = Dri + m.Properties["VolumeSerialNumber"].Value.ToString();
break;
}
}
}
return Dri;
}
private clsIDE()
{
}
}
}