本文介绍了如何获取哪个硬盘的可启动硬盘或系统的主磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取硬盘序列号以为我的应用程序生成许可证。在互联网上搜索后我发现这个







但是..使用Win32_DiskDrive管理对象我可以获得硬盘的序列号但是来自如何才能将哪个硬盘用作主磁盘?

I want to get hard disk serial number to generate a licence for my application. after searching on the internet I found this

HERE

But .. using Win32_DiskDrive management object I can get serial number of hard disk but from the list, how can get which hard disk use as primary disk ?

推荐答案

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");

foreach (ManagementObject managementObject in searcher.Get())
{
    Console.WriteLine(managementObject["DeviceId"].ToString());
    Console.WriteLine(managementObject["Index"].ToString());
}

Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskPartition");

foreach (ManagementObject managementObject in searcher.Get())
{
    Console.WriteLine(managementObject["DeviceId"].ToString());
    Console.WriteLine(managementObject["Index"].ToString());
    Console.WriteLine(managementObject["Bootable"].ToString());
    Console.WriteLine(managementObject["BootPartition"].ToString());
}

Console.ReadKey();


virusstorm, But I want to get the serial number for the physical DISK, from your code I can get which DRIVE is boot one, But I still stuck on how can I get the SN for the DISK that have this boo partition ?

Thanks


这篇关于如何获取哪个硬盘的可启动硬盘或系统的主磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 06:51