用戶名:  密碼:  驗證碼: 驗證碼  注冊  找回
RSS
無雙網
 2019年10月16日 星期三  您現在位于: 首頁 → 技術文欄 → 用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


 (本文已被瀏覽 15411 次)
 發布人:asp126
 → 推薦給我的好友
上篇文章:在Delphi里播放Flash
下篇文章:能否判斷動態數組有沒有被分配過
發表評論
  → 評論內容 (點擊查看)   共0條評論,每頁顯示5條評論   瀏覽所有評論
(沒有相關評論)
  → 發表我的評論 (點擊發表)
熱門文章
 保存webbrowser中的HTML內...
 用VB6.0設計簡易賽車游戲
 MSFlexGrid使用技巧一例
 游戲對照表
 Win2003+Discuz!5.5+II...
 添加紅月裝備的詳細教程 (包括裝備 武...
 全部DLL下載
 在Delphi里播放Flash
 用vb6的ActiveX控件實現異步下...
 能否判斷動態數組有沒有被分配過
最新文章
 [ODBC SQL Server Driv...
 評論:115網盤的何去何從
 我科學家實現百公里量級自由空間量子隱形...
 中國智能手機出貨量占全球27%居世界之...
 Gartner:2012 第二季度西歐 P...
 [多圖]華山論劍:當今在世的智商最高的...
 三星獲出租車服務系統專利 可快速查看駕...
 [多圖]15項可能延續到2030年的科...
 分析稱蘋果三星專利大戰輸贏已成定論
 Google終獲云操作系統專利
 網站留言· 友情鏈接·與我在線·網站地圖聯系我們·管理·TOP 
 陜ICP備14011112號  
 Copyright © 2012 Asp126.com Inc. All Rights Reserved.Processed in 0.000s, 8 queries, 35 Cache,0 Online  
福建11选5遗漏