我从网上搜集了一些例子,但是返回的都是空值,据说是获得IDE硬盘用的,找到一个DLL可以获得,反汇编后看不懂⊙⊙?。请问一下,应该怎样获得呢?

解决方案 »

  1.   

    没玩过SCSI硬盘,不知道,顶一下
    如果您知道的话请告诉我
    [email protected]
      

  2.   

    我用的手机,DLL叫共享软件加密算法库,网上有的,不光有DLL
      

  3.   

    取得SCSI的和IDE的有什么区别吗?
      

  4.   

    不知道这个对你有用不?
    http://download.csdn.net/source/1707918
      

  5.   

    唉,我只能用手机,没法贴代码,CSDN貌似不支持手机下载
      

  6.   

    不知道是不是你想要的:
    调用API函数 GetVolumeInformation。
    API声明:
    Declare Function GetVolumeInformation Lib "kernel32" _
      Alias "GetVolumeInformationA" _
      (ByVal lpRootPathName As String, _
      ByVal lpVolumeNameBuffer As String, _
      ByVal nVolumeNameSize As Long, _
      lpVolumeSerialNumber As Long, _
      lpMaximumComponentLength As Long, _
      lpFileSystemFlags As Long, _
      ByVal lpFileSystemNameBuffer As String, _
      ByVal nFileSystemNameSize As Long) As Long程序:Private Sub Form_Load()
      Dim sDriveLetter As String 
      Dim RetVal As Long 
      Dim lpName As String 
      Dim nSize As Long 
      Dim nSerial As Long 
      Dim lpMaxComp As Long 
      Dim nFileFlags As Long 
      Dim lpFileName As String 
      lpName = Space(255)
      lpFileName = Space(255)
      nSize = 255  sDriveLetter = "a:\" ’这里你可以指定任何盘号  RetVal = GetVolumeInformation(sDriveLetter, lpName, _
       nSize, nSerial, lpMaxComp, nFileFlags, lpFileName, nSize)
      '你可以看出,不仅能得到序列号,还可以得到其他很多信息  If RetVal = 0 Then 
        '这里是你的错误处理代码
        Exit Sub 'Quit the subroutine
      Else 
        lblDriveSerial.Caption = CStr(nSerial) 
        '假定你已经建立了这个标签,将在标签上显示序列号.
      End If
    End Sub
      

  7.   

    http://topic.csdn.net/t/20050704/08/4120593.html
      

  8.   

    取得硬盘物理序列号:
    http://www.cnblogs.com/wangminbai/articles/1076182.html
      

  9.   

    这个我用过了,但得到的getdeskinfo的值是-1,所以后面就不执行了,我用一个字符串接收返回值,结果是空的啊
      

  10.   

    获取硬盘序号和型号及固件版本'建窗体,窗体放置1个ComBox,命名为cbDrive,1个ListBox,命名为lstMain,一个CommandButton,命名为cmdGo,添加如下代码:Dim h As clsMainInfoPrivate Sub cmdGo_Click()    Dim hT As Long
        Dim uW() As Byte
        Dim dW() As Byte
        Dim pW() As Byte
        
        Set h = New clsMainInfo
        
        With h
            .CurrentDrive = Val(cbDrive.Text)
             lstMain.Clear
             lstMain.AddItem "当前驱动器: " & .CurrentDrive
             lstMain.AddItem ""
             lstMain.AddItem "硬盘型号: " & .GetModelNumber
             lstMain.AddItem "序列号: " & .GetSerialNumber
             lstMain.AddItem "固件版本: " & .GetFirmwareRevision
        End With
        
        Set h = Nothing
        
    End SubPrivate Sub Form_Load()
        cbDrive.AddItem 0
        cbDrive.AddItem 1
        cbDrive.AddItem 2
        cbDrive.AddItem 3
        cbDrive.ListIndex = 0
    End Sub
    '-------------------添加类模块-------------------------Option ExplicitPrivate Const VER_PLATFORM_WIN32S [color=#0000ff]= 0
    Private Const VER_PLATFORM_WIN32_WINDOWS = 1
    Private Const VER_PLATFORM_WIN32_NT = 2Private Const DFP_RECEIVE_DRIVE_DATA = &H7C088Private Const FILE_SHARE_READ = &H1
    Private Const FILE_SHARE_WRITE = &H2
    Private Const GENERIC_READ = &H80000000
    Private Const GENERIC_WRITE = &H40000000
    Private Const OPEN_EXISTING = 3
    Private Const Create_NEW = 1Private Enum HDINFO
        HD_MODEL_NUMBER
        HD_SERIAL_NUMBER
        HD_FIRMWARE_REVISION
    End EnumPrivate Type OSVERSIONINFO
        dwOSVersionInfoSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformId As Long
        szCSDVersion As String * 128
    End TypePrivate Type IDEREGS
        bFeaturesReg As Byte
        bSectorCountReg As Byte
        bSectorNumberReg As Byte
        bCylLowReg As Byte
        bCylHighReg As Byte
        bDriveHeadReg As Byte
        bCommandReg As Byte
        bReserved As Byte
    End TypePrivate Type SENDCMDINPARAMS
        cBufferSize As Long
        irDriveRegs As IDEREGS
        bDriveNumber As Byte
        bReserved(1 To 3) As Byte
        dwReserved(1 To 4) As Long
    End TypePrivate Type DRIVERSTATUS
        bDriveError As Byte
        bIDEStatus As Byte
        bReserved(1 To 2) As Byte
        dwReserved(1 To 2) As Long
    End TypePrivate Type SENDCMDOUTPARAMS
        cBufferSize As Long
        DStatus As DRIVERSTATUS
        bBuffer(1 To 512) As Byte
    End TypePrivate Declare Function GetVersionEx _
        Lib "kernel32" Alias "GetVersionExA" _
        (lpVersionInformation As OSVERSIONINFO) As LongPrivate Declare Function CreateFile _
        Lib "kernel32" Alias "CreateFileA" _
        (ByVal lpFileName As String, _
        ByVal dwDesiredAccess As Long, _
        ByVal dwShareMode As Long, _
        ByVal lpSecurityAttributes As Long, _
        ByVal dwCreationDisposition As Long, _
        ByVal dwFlagsAndAttributes As Long, _
        ByVal hTemplateFile As Long) As LongPrivate Declare Function CloseHandle _
        Lib "kernel32" _
        (ByVal hObject As Long) As LongPrivate Declare Function DeviceIoControl _
        Lib "kernel32" _
        (ByVal hDevice As Long, _
        ByVal dwIoControlCode As Long, _
        lpInBuffer As Any, _
        ByVal nInBufferSize As Long, _
        lpOutBuffer As Any, _
        ByVal nOutBufferSize As Long, _
        lpBytesReturned As Long, _
        ByVal lpOverlapped As Long) As Long
        
    Private Declare Sub ZeroMemory _
        Lib "kernel32" Alias "RtlZeroMemory" _
        (dest As Any, _
        ByVal numBytes As Long)Private Declare Sub CopyMemory _
        Lib "kernel32" Alias "RtlMoveMemory" _
        (Destination As Any, _
        Source As Any, _
        ByVal Length As Long)Private Declare Function GetLastError _
        Lib "kernel32" () As LongPrivate mvarCurrentDrive As Byte
    Private mvarPlatform As StringPublic Function GetModelNumber() As String
        
        GetModelNumber = CmnGetHDData(HD_MODEL_NUMBER)
        
    End FunctionPublic Function GetSerialNumber() As String
        
        GetSerialNumber = CmnGetHDData(HD_SERIAL_NUMBER)
        
    End FunctionPublic Function GetFirmwareRevision() As String
        
        GetFirmwareRevision = CmnGetHDData(HD_FIRMWARE_REVISION)
        
    End FunctionPublic Property Let CurrentDrive(ByVal vData As Byte)
        
        If vData < 0 or vData > 3 Then
            Err.Raise 10000, , "Illegal Drive Number"
        End If
        
        mvarCurrentDrive = vDataEnd PropertyPublic Property Get CurrentDrive() As Byte
        
        CurrentDrive = mvarCurrentDriveEnd PropertyPublic Property Get Platform() As String
        
        Platform = mvarPlatformEnd PropertyPrivate Sub Class_Initialize()    Dim OS As OSVERSIONINFO
            
        OS.dwOSVersionInfoSize = Len(OS)
        Call GetVersionEx(OS)
        mvarPlatform = "Unk"
        Select Case OS.dwPlatformId
            Case Is = VER_PLATFORM_WIN32S
                mvarPlatform = "32S"
            Case Is = VER_PLATFORM_WIN32_WINDOWS
                If OS.dwMinorVersion = 0 Then
                    mvarPlatform = "W95"
                Else
                    mvarPlatform = "W98"
                End If
            Case Is = VER_PLATFORM_WIN32_NT
                mvarPlatform = "WNT"
        End SelectEnd SubPrivate Function CmnGetHDData(hdi As HDINFO) As String    Dim bin As SENDCMDINPARAMS
        Dim bout As SENDCMDOUTPARAMS
        Dim hdh As Long
        Dim br As Long
        Dim ix As Long
        Dim hddfr As Long
        Dim hddln As Long
        Dim s As String
        
        Select Case hdi
            Case HD_MODEL_NUMBER
                hddfr = 55
                hddln = 40
            Case HD_SERIAL_NUMBER
                hddfr = 21
                hddln = 20
            Case HD_FIRMWARE_REVISION
                hddfr = 47
                hddln = 8
            Case Else
                Err.Raise 10001, "Illegal HD Data type"
        End Select
        
        Select Case mvarPlatform
            Case "WNT"
                hdh = CreateFile("\\.\PhysicalDrive" & mvarCurrentDrive, _
                    GENERIC_READ + GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, _
                    0, OPEN_EXISTING, 0, 0)
            Case "W95", "W98"
                hdh = CreateFile("\\.\Smartvsd", _
                    0, 0, 0, Create_NEW, 0, 0)
            Case Else
                Err.Raise 10002, , "Illegal platform (only WNT, W98 or W95)"
        End Select
        
        If hdh = 0 Then
            Err.Raise 10003, , "Error on CreateFile"
        End If
        
        ZeroMemory bin, Len(bin)
        ZeroMemory bout, Len(bout)
        
        With bin
            .bDriveNumber = mvarCurrentDrive
            .cBufferSize = 512
            With .irDriveRegs
                If (mvarCurrentDrive And 1) Then
                    .bDriveHeadReg = &HB0
                Else
                    .bDriveHeadReg = &HA0
                End If
                .bCommandReg = &HEC
                .bSectorCountReg = 1
                .bSectorNumberReg = 1
            End With
        End With
        
        DeviceIoControl hdh, DFP_RECEIVE_DRIVE_DATA, _
                        bin, Len(bin), bout, Len(bout), br, 0
        
        s = vbNullString
        For ix = hddfr To hddfr + hddln - 1 Step 2
            If bout.bBuffer(ix + 1) = 0 Then Exit For
            s = s & Chr(bout.bBuffer(ix + 1))
            If bout.bBuffer(ix) = 0 Then Exit For
            s = s & Chr(bout.bBuffer(ix))
        Next ix
        
        CloseHandle hdh    CmnGetHDData = Trim(s)
        
    End Function
      

  11.   

    SCSI 硬盘不行吗?我只有 EIDE 的,试过,倒还可以。
    不知道 SCSI 的硬盘行不。
      

  12.   

    下载个《驱动人生》
    文件夹下有个pcinfo.dll
    Private Declare Function GetHardDiskSerial Lib "pcinfo.dll" () As String
    Private Declare Function GetNetMac Lib "pcinfo.dll" () As String