用户名:  密码:  验证码: 验证码  注册  找回
RSS
无双网
 2018年05月26日 星期六  您现在位于: 首页 → 技术文栏 → 用diskid.dll和disk32.dll获得硬盘序列号-...

用diskid.dll和disk32.dll获得硬盘序列号

2008年04月18日  无双网  出处:CSDN

1.调用diskid.dll实现:

Option Explicit
Private Declare Function IsWinNT Lib "DiskID.DLL" () As Long
Private Declare Function ReadPhysicalDrive9X Lib "DiskID.DLL" (driveID As Long, buffer As Long, bufLen As Long) As Long
Private Declare Function ReadPhysicalDriveInNT Lib "DiskID.DLL" (driveID As Long, buffer As Long, bufLen As Long) As Long

Private Type DRIVER_INFO_OK
    ModalNumber(39) As Byte
    SerialNumber(19) As Byte
    ControlNum(7) As Byte
    DriveType As Long
    Cylinders As Long
    Heads As Long
    Sectors As Long
End Type

Private Sub Command1_Click()
    Dim x As DRIVER_INFO_OK
    Dim i As Long
    If IsWinNT = 1 Then
        i = ReadPhysicalDriveInNT(ByVal 0, ByVal VarPtr(x), ByVal 256)
    Else
        i = ReadPhysicalDrive9X(ByVal 0, ByVal VarPtr(x), ByVal 256)
    End If
    Dim s As String
    s = StrConv(x.ModalNumber, vbUnicode)
    s = Left(s, InStr(1, s, Chr(0)) - 1)
    MsgBox "硬件厂商代码为:" + s
    s = StrConv(x.SerialNumber, vbUnicode)
    s = Left(s, InStr(1, s, Chr(0)) - 1)
    MsgBox "硬盘序列号为:" + s
End Sub

2.调用diskid32.dll实现:

Option Explicit
Private Declare Function DiskID32 Lib "DiskID32.DLL" (ByRef DiskModel As Byte, ByRef DiskID As Byte) As Long

Private Sub Command1_Click()
    Dim DiskModel(31) As Byte, DiskID(31) As Byte, i As Integer, Model As String, ID As String
    If DiskID32(DiskModel(0), DiskID(0)) <> 1 Then
        MsgBox "get diskid32 err"
        Exit Sub
    End If
    For i = 0 To 31
        If Chr(DiskModel(i)) <> Chr(0) Then
            Model = Model & Chr(DiskModel(i))
        End If
        If Chr(DiskID(i)) <> Chr(0) Then
            ID = ID & Chr(DiskID(i))
        End If
    Next
    MsgBox "硬件产生代码为:" + Model
    MsgBox "硬盘序列号为:" + ID

End Sub


 (本文已被浏览 9554 次)
 发布人:asp126
 → 推荐给我的好友
上篇文章:在Delphi里播放Flash
下篇文章:能否判断动态数组有没有被分配过
发表评论
  → 评论内容 (点击查看)   共0条评论,每页显示5条评论   浏览所有评论
(没有相关评论)
  → 发表我的评论 (点击发表)
热门文章
 全部DLL下载
 手机解锁大全
 添加红月装备的详细教程 (包括装备 武...
 42个搜索引擎免费登陆入口大全 (国内...
 MSFlexGrid使用技巧一例
 保存webbrowser中的HTML内...
 用vb6的ActiveX控件实现异步下...
 PC经典RPG《仙剑奇侠传Ⅰ》for PP...
 用VB6.0设计简易赛车游戏
 能否判断动态数组有没有被分配过
最新文章
 [ODBC SQL Server Driv...
 评论:115网盘的何去何从
 我科学家实现百公里量级自由空间量子隐形...
 中国智能手机出货量占全球27%居世界之...
 Gartner:2012 第二季度西欧 P...
 [多图]华山论剑:当今在世的智商最高的...
 三星获出租车服务系统专利 可快速查看驾...
 [多图]15项可能延续到2030年的科...
 分析称苹果三星专利大战输赢已成定论
 Google终获云操作系统专利
 网站留言· 友情链接·与我在线·网站地图联系我们·管理·TOP 
 陕ICP备09004157号  
 Copyright © 2012 Asp126.com Inc. All Rights Reserved.Processed in 0.015s, 8 queries, 34 Cache,0 Online