在Delphi7中,如何检索硬盘唯一序列号?
你好 我想检索硬盘唯一(硬件)序列号。 我使用了一些功能,但在 Windows 7 或 Vista 中,由于管理员权限,它们无法正常工作。 是否可以在不以管理员身份运行的情况下检索它?
Hi
I want to retrieve HDD unique (hardware) serial number.
I use some functions but in Windows Seven or Vista they don't work correctly because of admin right.
Is it possible retrieve it without run as Administrator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
按照发布的问题评论 Sertac 中的链接,我遇到了这个 有趣的 C++ 问题,其中 Fredou 回答了一个很好的链接,指向 展示如何在 .NET 中执行此操作的代码项目示例,该示例又基于 Borland C++ 代码链接 和 文章。
最酷的是此 C++ 代码也可以作为非管理员用户使用!
现在您需要有人帮助您将此 C++ 代码翻译为 Delphi。
编辑:找到了一个可以为您执行此操作的Delphi单元。
我为它编写了一些示例使用:
单元来自http://www.delphipraxis.net/564756-post28.html
编辑:RAID 配置需要特殊规定。
例如,我有一个带有多个 RAID 5 阵列的 RAID 系统;仅显示第一个,并且不显示驱动器序列号,而是显示 RAID 阵列的序列号:
--jeroen
Following the links in the question comments Sertac posted, I came across this interesting C++ question, where Fredou answered with a nice link to a codeproject example showing how to do this in .NET, which in turn was based on a link to Borland C++ code and article.
The cool thing is that this C++ code works as a non-administrator user too!
Now you need someone to help you translate this C++ code to Delphi.
Edit: Found a Delphi unit that does this for you.
I wrote some sample use for it:
Unit from http://www.delphipraxis.net/564756-post28.html
Edit: RAID configurations require special provisions.
For instance, I got a RAID system with multiple RAID 5 array; only the first one displays, and it does not show the drive serial numbers, but the serial number of the RAID array:
--jeroen
您可以使用
WMI(Windows 管理Instrumentation)
获取与 Windows 硬件相关的信息。存在两个 wmi 类,它们公开一个名为
SerialNumber
的属性,该属性存储制造商分配的用于标识物理介质的编号。
这些类是Win32_DiskDrive
和
Win32_PhysicalMedia
。要访问这些类的SerialNumber
属性,您必须知道磁盘的DeviceId
,类似于\\. \PHYSICALDRIVE0
。另一种方法是使用关联类,将物理驱动器与逻辑驱动器(C、D、E)链接起来,因此您必须先找到此链接才能获取序列号。找到这个关联的顺序是这样的。
Win32_DiskPartition
->Win32_LogicalDiskToPartition
->Win32_DiskDrive
注释 1:
Win32_DiskDrive
类的SerialNumber
属性在 Windows Server 2003、Windows XP、Windows 2000 和 Windows NT 4.0 中不存在,所以您所说的使用 Windows Vista 或 Windows 7 的方式对您来说应该没问题。注2:该代码不需要管理员帐户即可运行。
检查这个代码
You can use the
WMI (Windows Management Instrumentation)
to get information related to windows hardware.Exist two wmi classes wich exposes a property called
SerialNumber
which storethe Number allocated by the manufacturer to identify the physical media.
these classes areWin32_DiskDrive
andWin32_PhysicalMedia
.to access theSerialNumber
property of these classes you must know theDeviceId
of the Disk which is something like this\\.\PHYSICALDRIVE0
. Another way is use a association class which link the Physical drive with the logical drive (C,D,E)so you must find this link previous to obtain the serial number. the sequence to find this association is like this.
Win32_DiskPartition
->Win32_LogicalDiskToPartition
->Win32_DiskDrive
Note 1 : The
SerialNumber
property for theWin32_DiskDrive
class does not exist in Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0, so how you are talking about use Windows Vista or Windows 7, will work ok for you.Note 2 : The code does not require a administrator account to run.
check this code
这是另一个 DiskId32 Victor Derevyanko
项目从 C++ 到 Delphi 的翻译:
http://code.google.com/p/dvsrc/
因为第一种方法(WithZeroRights )对我来说不起作用,我为 ReadIdeDriveAsScsiDriveInNT 方法编写了另一个:
示例用法:
这对于我的 WD 磁盘非常有用。
Here is another DiskId32 translation from C++ to Delphi by Victor Derevyanko
project:
http://code.google.com/p/dvsrc/
Because the first method (WithZeroRights) doesn't work for me, I wrote another for ReadIdeDriveAsScsiDriveInNT method:
Sample usage:
This works great with my WD disk.
我找到了这段代码,它已修复并在 Windows 7 64 上与我正常工作
https://code.google.com/p/dvsrc/downloads/detail?name=20120116DiskId32Port_fixed.7z&can=2&q=
这是他的所有工作
< a href="https://code.google.com/p/dvsrc/downloads/list" rel="nofollow">https://code.google.com/p/dvsrc/downloads/list
I found this code, it is fixed one and working fine with me on windows 7 64
https://code.google.com/p/dvsrc/downloads/detail?name=20120116DiskId32Port_fixed.7z&can=2&q=
and this his all work
https://code.google.com/p/dvsrc/downloads/list
发布此内容纯粹是为了完整性,并可能满足那些感兴趣或顽固的硬件狂热者。
我没有可用的 Pascal 编译器来在当前的 Windows 系统上测试这些例程,但我确实知道这段代码可以在 DOS 时代运行。也许它仍然可以在命令提示符窗口中运行。
Pascal 代码:
请随时更新此答案,以便使其在 Delphi 中工作(如果可能的话)。
Posting this purely for completeness sake, and to possibly satisfy those interested or die hard hardware fanatics.
I do not have a Pascal compiler at my disposal to test these routines on current Windows systems, but I do know this code worked back in the DOS era. Maybe it still works from a command prompt window.
Pascal code:
Please feel free to update this answer in order to get it working (if possible at all) in Delphi.