[DllImport("DiskID32.dll")]
public static extern long DiskID32(ref byte DiskModel, ref byte DiskID);
private string GetHardDiskID()
{
byte[] DiskModel = new byte[31];
byte[] DiskID = new byte[31];
int i;
string Model = "";
string HDDID = "";
if (DiskID32(ref DiskModel[0], ref DiskID[0]) != 1)
{
for (i = 0; i < 31; i++)
{
if (Convert.ToChar(DiskID[i]) != Convert.ToChar(0))
{
HDDID = HDDID + Convert.ToChar(DiskID[i]);
}
}
HDDID = HDDID.Trim();
}
else
{
HDDID = "";
}
return HDDID;
}