请问一下如何获得主板和硬盘的ID
谢谢大家了

解决方案 »

  1.   

    硬盘序列号
    http://vip.6to23.com/NowCan1/tech/vb_hd_info.htm
    http://vip.6to23.com/NowCan1/code/hd_info.zip
    www.jiaxinda.com/dont_delete/98及2K取硬盘id号_类.exe
      

  2.   

    最后一个关键的下不了啊
    THS
      

  3.   

    mailto: [email protected] 给你发个例子
      

  4.   

    也许你并不了解硬盘分区信息应该包括些什么,但如果你曾经对硬盘分过区,你或许对此有所了解,在此为各位介绍一个用VB编写的获取硬盘分区信息的程序。在这个程序中,它将详细地告诉你:你的硬盘总容量、分过几个区、每个区的总容量、及现在剩余的可用容量、硬盘分区表为几位(即是FAT32还是FAT16),每个分区是几个字节……怎么样?够完整详细了吧!好的,就让我们一起来看一下吧:
      首先做准备工作:在FORM1上新建二个LABEL(LABEL1和LABEL2)一个COMMAND1命令按钮。然后输入以下代码:
      Private Declare Function GetDriveType Lib 
      kernel32“Alias "GetDriveTypeA(ByVal nDrive As String) As Long
      Private Declare Function GetDiskFreeSpace Lib“kernel32" Alias“GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long
      Private Const DRIVE_FIXED = 3
      Private Sub Form_Load() '作初始化设置
      COMMAND1.Caption = “测试硬盘"
      Form1.Caption = “测试硬盘程序"
      Label1.WordWrap = True
      Label1.Caption = “"
      Label2.WordWrap = True
      Label2.Caption = “"
      End Sub
      Private Sub COMMAND1_Click()
      Dim DriveNum As Integer
      Dim TempDrive As String
      Dim X As Long
      For DriveNum = 97 To 122 Step 1 '检测从A-Z(盘符)
      TempDrive = GetDriveType(Chr(DriveNum) & “:\")
      Select Case TempDrive '如是3则表示是硬盘,测试你有几个盘
      Case 3: X = GetDiskSpace(Chr(DriveNum)) '调用子程序
      End Select
      Next DriveNum
      End Sub
      Public Function GetDiskSpace(DrivePath As String)
      Dim Drive As String
      Dim SectorsPerCluster As Long
      Dim BytesPerSector As Long
      Dim NumberOfFreeClusters As Long
      Dim TotalClusters As Long
      Dim Check As Integer
      Dim DiskSpace
      Dim diskTotal
      Static AllDiskTotal As Long
      Static NUM As Integer
      NUM = NUM + 1 '分几个区的计算
      Drive = Left(Trim(DrivePath), 1) & “:\"
      Check = GetDiskFreeSpace(Drive, SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalClusters)
      If Check <> 0 Then
      DiskSpace = SectorsPerCluster * BytesPerSector * NumberOfFreeClusters
      '这是一个分区磁盘剩余空间的计算公式
      DiskSpace = Format$(DiskSpace, “###,###") '以规定格式显示,如732,324,231
      diskTotal = SectorsPerCluster * BytesPerSector * TotalClusters
      '这是一个分区磁盘总容量的计算公式
      diskTotal = Format$(diskTotal, “###,###")
      AllDiskTotal = AllDiskTotal + diskTotal '整个硬盘的总容量
      Label1.Caption =“你的硬盘总容量为:” & Format$(AllDiskTotal,“###,###") &个字节,即:” & Left(AllDiskTotal, 1) & . & Mid(AllDiskTotal, 2, 1) &“G,一共分了”& NUM &“个区,其中:"
       Label2.Caption = Label2.Caption & UCase(DrivePath) & “盘的整个容量为:" & diskTotal &“个字节" & ",其剩余磁盘空间为:“& DiskSpace & " 个字节,磁盘已FAT“& SectorsPerCluster & ",每个分区为:“& BytesPerSector & "个字节。“& vbCrLf & vbCrLf”
      End If
      End Function
      OK!现在你运行一下,你是否满意它?
      注:以上程序在中文WINDOWS98,中文VB6.0企业版中调试通过。 
      

  5.   

    硬盘的厂商序列号无法在VB中获得,只能获得操作系统格式化时产生的序列号:
    下面的这个例子是使用GetVolumeInformation获得磁盘的序列号: 
        Private Declare Function GetVolumeInformation Lib _ 
         "kernel32.dll" Alias "GetVolumeInformationA" (ByVal _ 
         lpRootPathName As String, ByVal lpVolumeNameBuffer As _ 
         String, ByVal nVolumeNameSize As Integer, _ 
         lpVolumeSerialNumber As Long, lpMaximumComponentLength _ 
         As Long, lpFileSystemFlags As Long, ByVal _ 
         lpFileSystemNameBuffer As String, ByVal _ 
         nFileSystemNameSize As Long) As Long 
         
         Function GetSerialNumber(strDrive As String) As Long 
         Dim SerialNum As Long 
         Dim Res As Long 
         Dim Temp1 As String 
         Dim Temp2 As String 
         Temp1 = String$(255, Chr$(0)) 
         Temp2 = String$(255, Chr$(0)) 
         Res = GetVolumeInformation(strDrive, Temp1, _ 
         Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2)) 
         GetSerialNumber = SerialNum 
         End Function     调用时使用GetSerialNumber("C:\")就可以了。 
         
      

  6.   

    这是以前的,没有问题,我现在安装成WIN2000了,也不能给你试了,真是不好意思.
      

  7.   

    [email protected]
    这是我的E-MAIL
      

  8.   

    '获得硬盘及网卡序列号
    Option Explicit
    Private LCW As Integer                 'Length of CodeWord
    Private LS2E As Integer                'Length of String to be Encrypted
    Private LAM As Integer                 'Length of Array Matrix
    Private MP As Integer                    'Matrix Position
    Private Matrix As String                  'Starting Matrix
    Private mov1 As String                    'First Part of Replacement String
    Private mov2 As String                    'Second Part of Replacement String
    Private CodeWord As String            'CodeWord
    Private CWL As String                    'CodeWord Letter
    Private EncryptedString As String     'String to Return for Encrypt or String to UnEncrypt for UnEncrypt
    Private EncryptedLetter As String     'Storage Variable for Character just Encrypted
    Private strCryptMatrix(97) As String 'Matrix ArrayPrivate Declare Function GetVolumeInformation Lib _
         "kernel32.dll" Alias "GetVolumeInformationA" (ByVal _
         lpRootPathName As String, ByVal lpVolumeNameBuffer As _
         String, ByVal nVolumeNameSize As Integer, _
         lpVolumeSerialNumber As Long, lpMaximumComponentLength _
         As Long, lpFileSystemFlags As Long, ByVal _
         lpFileSystemNameBuffer As String, ByVal _
         nFileSystemNameSize As Long) As Long
         
    '获取计算机名
    Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
    Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    '获取计算机名'获取网卡号
    Private Const NCBASTAT = &H33
    Private Const NCBNAMSZ = 16
    Private Const HEAP_ZERO_MEMORY = &H8
    Private Const HEAP_GENERATE_EXCEPTIONS = &H4
    Private Const NCBRESET = &H32Private Type NCB
      ncb_command As Byte
      ncb_retcode As Byte
      ncb_lsn As Byte
      ncb_num As Byte
      ncb_buffer As Long
      ncb_length As Integer
      ncb_callname As String * NCBNAMSZ
      ncb_name As String * NCBNAMSZ
      ncb_rto As Byte
      ncb_sto As Byte
      ncb_post As Long
      ncb_lana_num As Byte
      ncb_cmd_cplt As Byte
      ncb_reserve(9) As Byte ' Reserved, must be 0
      ncb_event As Long
    End TypePrivate Type ADAPTER_STATUS
      adapter_address(5) As Byte
      rev_major As Byte
      reserved0 As Byte
      adapter_type As Byte
      rev_minor As Byte
      duration As Integer
      frmr_recv As Integer
      frmr_xmit As Integer
      iframe_recv_err As Integer
      xmit_aborts As Integer
      xmit_success As Long
      recv_success As Long
      iframe_xmit_err As Integer
      recv_buff_unavail As Integer
      t1_timeouts As Integer
      ti_timeouts As Integer
      Reserved1 As Long
      free_ncbs As Integer
      max_cfg_ncbs As Integer
      max_ncbs As Integer
      xmit_buf_unavail As Integer
      max_dgram_size As Integer
      pending_sess As Integer
      max_cfg_sess As Integer
      max_sess As Integer
      max_sess_pkt_size As Integer
      name_count As Integer
    End TypePrivate Type NAME_BUFFER
      name As String * NCBNAMSZ
      name_num As Integer
      name_flags As Integer
    End TypePrivate Type ASTAT
      adapt As ADAPTER_STATUS
      NameBuff(30) As NAME_BUFFER
    End TypePrivate Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
    Private Declare Function GetProcessHeap Lib "kernel32" () As Long
    Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
    Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
             
    Public Function GetSerialNumber(Optional strDrive As String = "C:\") As Long
    '功能:根据传入的磁盘符号获取序列号 C:\
    Dim SerialNum As Long
    Dim Res As Long
    Dim temp1 As String
    Dim Temp2 As String
    On Error GoTo ErrShow
        temp1 = String$(255, Chr$(0))
        Temp2 = String$(255, Chr$(0))
        Res = GetVolumeInformation(strDrive, temp1, _
        Len(temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
        GetSerialNumber = SerialNum
        Exit Function
    ErrShow:
        MsgBox Err.Description & "GetSerialNumber", vbInformation, Soft
        Err.Clear
    End Function
        
    Public Function GetEthernetAddress(Optional LanaNumber As Long) As String
      Dim udtNCB       As NCB
      Dim bytResponse  As Byte
      Dim udtASTAT     As ASTAT
      Dim udtTempASTAT As ASTAT
      Dim lngASTAT     As Long
      Dim strOut       As String
      Dim x            As Integer
    On Error GoTo ErrShow
      udtNCB.ncb_command = NCBRESET
      bytResponse = Netbios(udtNCB)
      udtNCB.ncb_command = NCBASTAT
      udtNCB.ncb_lana_num = LanaNumber
      udtNCB.ncb_callname = "* "
      udtNCB.ncb_length = Len(udtASTAT)
      lngASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, udtNCB.ncb_length)
      strOut = ""
      If lngASTAT Then
        udtNCB.ncb_buffer = lngASTAT
        bytResponse = Netbios(udtNCB)
        CopyMemory udtASTAT, udtNCB.ncb_buffer, Len(udtASTAT)
         With udtASTAT.adapt
          For x = 0 To 5
            strOut = strOut & Right$("00" & Hex$(.adapter_address(x)), 2)
          Next x
        End With
        HeapFree GetProcessHeap(), 0, lngASTAT
      End If
      GetEthernetAddress = strOut
      Exit Function
    ErrShow:
      MsgBox Err.Description & "GetEt", vbInformation, Soft
      Err.Clear
    End Function
      

  9.   

    Private LCW As Integer                 'Length of CodeWord
    Private LS2E As Integer                'Length of String to be Encrypted
    Private LAM As Integer                 'Length of Array Matrix
    Private MP As Integer                    'Matrix Position
    Private Matrix As String                  'Starting Matrix
    Private mov1 As String                    'First Part of Replacement String
    Private mov2 As String                    'Second Part of Replacement String
    Private CodeWord As String            'CodeWord
    Private CWL As String                    'CodeWord Letter
    Private EncryptedString As String     'String to Return for Encrypt or String to UnEncrypt for UnEncrypt
    Private EncryptedLetter As String     'Storage Variable for Character just Encrypted
    Private strCryptMatrix(97) As String 'Matrix ArrayPrivate Declare Function GetVolumeInformation Lib _
         "kernel32.dll" Alias "GetVolumeInformationA" (ByVal _
         lpRootPathName As String, ByVal lpVolumeNameBuffer As _
         String, ByVal nVolumeNameSize As Integer, _
         lpVolumeSerialNumber As Long, lpMaximumComponentLength _
         As Long, lpFileSystemFlags As Long, ByVal _
         lpFileSystemNameBuffer As String, ByVal _
         nFileSystemNameSize As Long) As Long
         
    '获取计算机名
    Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
    Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    '获取计算机名'获取网卡号
    Private Const NCBASTAT = &H33
    Private Const NCBNAMSZ = 16
    Private Const HEAP_ZERO_MEMORY = &H8
    Private Const HEAP_GENERATE_EXCEPTIONS = &H4
    Private Const NCBRESET = &H32Private Type NCB
      ncb_command As Byte
      ncb_retcode As Byte
      ncb_lsn As Byte
      ncb_num As Byte
      ncb_buffer As Long
      ncb_length As Integer
      ncb_callname As String * NCBNAMSZ
      ncb_name As String * NCBNAMSZ
      ncb_rto As Byte
      ncb_sto As Byte
      ncb_post As Long
      ncb_lana_num As Byte
      ncb_cmd_cplt As Byte
      ncb_reserve(9) As Byte ' Reserved, must be 0
      ncb_event As Long
    End TypePrivate Type ADAPTER_STATUS
      adapter_address(5) As Byte
      rev_major As Byte
      reserved0 As Byte
      adapter_type As Byte
      rev_minor As Byte
      duration As Integer
      frmr_recv As Integer
      frmr_xmit As Integer
      iframe_recv_err As Integer
      xmit_aborts As Integer
      xmit_success As Long
      recv_success As Long
      iframe_xmit_err As Integer
      recv_buff_unavail As Integer
      t1_timeouts As Integer
      ti_timeouts As Integer
      Reserved1 As Long
      free_ncbs As Integer
      max_cfg_ncbs As Integer
      max_ncbs As Integer
      xmit_buf_unavail As Integer
      max_dgram_size As Integer
      pending_sess As Integer
      max_cfg_sess As Integer
      max_sess As Integer
      max_sess_pkt_size As Integer
      name_count As Integer
    End TypePrivate Type NAME_BUFFER
      name As String * NCBNAMSZ
      name_num As Integer
      name_flags As Integer
    End TypePrivate Type ASTAT
      adapt As ADAPTER_STATUS
      NameBuff(30) As NAME_BUFFER
    End TypePrivate Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
    Private Declare Function GetProcessHeap Lib "kernel32" () As Long
    Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
    Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
             
    Public Function GetSerialNumber(Optional strDrive As String = "C:\") As Long
    '功能:根据传入的磁盘符号获取序列号 C:\
    Dim SerialNum As Long
    Dim Res As Long
    Dim temp1 As String
    Dim Temp2 As String
    On Error GoTo ErrShow
        temp1 = String$(255, Chr$(0))
        Temp2 = String$(255, Chr$(0))
        Res = GetVolumeInformation(strDrive, temp1, _
        Len(temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
        GetSerialNumber = SerialNum
        Exit Function
    ErrShow:
        MsgBox Err.Description & "GetSerialNumber", vbInformation, Soft
        Err.Clear
    End Function
        
    Public Function GetEthernetAddress(Optional LanaNumber As Long) As String
      Dim udtNCB       As NCB
      Dim bytResponse  As Byte
      Dim udtASTAT     As ASTAT
      Dim udtTempASTAT As ASTAT
      Dim lngASTAT     As Long
      Dim strOut       As String
      Dim x            As Integer
    On Error GoTo ErrShow
      udtNCB.ncb_command = NCBRESET
      bytResponse = Netbios(udtNCB)
      udtNCB.ncb_command = NCBASTAT
      udtNCB.ncb_lana_num = LanaNumber
      udtNCB.ncb_callname = "* "
      udtNCB.ncb_length = Len(udtASTAT)
      lngASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, udtNCB.ncb_length)
      strOut = ""
      If lngASTAT Then
        udtNCB.ncb_buffer = lngASTAT
        bytResponse = Netbios(udtNCB)
        CopyMemory udtASTAT, udtNCB.ncb_buffer, Len(udtASTAT)
         With udtASTAT.adapt
          For x = 0 To 5
            strOut = strOut & Right$("00" & Hex$(.adapter_address(x)), 2)
          Next x
        End With
        HeapFree GetProcessHeap(), 0, lngASTAT
      End If
      GetEthernetAddress = strOut
      Exit Function
    ErrShow:
      MsgBox Err.Description & "GetEt", vbInformation, Soft
      Err.Clear
    End Function