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 取得硬盘的ID号
上面是声明,现在是程序。 程序: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
nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
取得硬盘的ID号
程序: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
还有就 网卡的 MAC Address 来作为 所谓的 机器码。
硬盘序列号;
网卡MAC地址;
。
CUP序列号;
硬盘序列号;
网卡MAC地址;
http://www.csdn.net/expert/topic/568/568496.xml?temp=.8400232