获取用于IDE和SATA的H/D序列号(非批量序列号) [英] Get H/D Serial number (Not Volumn Serial Number) for IDE and SATA

查看:147
本文介绍了获取用于IDE和SATA的H/D序列号(非批量序列号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在VB.NET中读取IDE和SATA驱动器的硬盘序列号? (我不需要卷序列号).

How can I read the hard disk serial number for IDE and SATA drives in VB.NET? (I don't want the volume serial number).

如果可能,应在没有管理权限的情况下为XP和Vista收集此信息.

This info should be gathered both for XP and Vista if possible without administrative rights.

推荐答案

您可以使用

You can use WMI (Windows Management Instrumentation) like this:

Dim mos As New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")

For Each mo As ManagementObject In mos.Get()
    Dim serial As String = mo("SerialNumber").ToString()
Next

尽管如此,我已经读过有关使用WMI不返回序列号的情况.实现此目的的另一种方法是通过平台调用服务(PInvoke).

Although, I've read about cases in which no serial number is returned using WMI. Another way to accomplish this would be through Platform Invocation Services (PInvoke).

文章包括下载,作者在其中实现了

This article includes a download in which the author implements CreateFile() and DeviceIoControl() to extract drive information through Interop services in VB .NET.

要使用上述概述的方法之一,您将需要具有ADMIN权限,可以找到一个似乎可以绕过此方法的实用程序源代码. (签出功能'ReadPhysicalDriveInNTWithZeroRights()')

To use either of the above outlined methods you will need ADMIN rights, a utility which seems to circumvent this can be found here. If your feeling adventurous the C++/Win32 source code is available for you to peruse. (Check out the function 'ReadPhysicalDriveInNTWithZeroRights()')

这篇关于获取用于IDE和SATA的H/D序列号(非批量序列号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆