Private Declare Function GetVolumeInformation& Lib "kernel32" _ Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, _ ByVal pVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _ lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _ lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _ ByVal nFileSystemNameSize As Long) Private Const MAX_FILENAME_LEN = 256 Public Function DriveSerial(ByVal sDrv As String) As Long 'Usage: 'Dim ds As Long 'ds = DriveSerial("C") Dim RetVal As Long Dim str As String * MAX_FILENAME_LEN Dim str2 As String * MAX_FILENAME_LEN Dim a As Long Dim b As Long GetVolumeInformation sDrv & ":\", str, MAX_FILENAME_LEN, RetVal, _ a, b, str2, MAX_FILENAME_LEN DriveSerial = RetVal End Function
磁盘序列号在每次软盘或硬盘格式化后都重新生成,并且不回重复。许多程序员用此加密。其实也可以修改该函数,可以得到磁盘卷标和文件系统类型信息。声明: 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(sRoot As String) As Long Dim lSerialNum As Long Dim R As Long Dim strLabel As String, strType As String strLabel = String$(255, Chr$(0)) '磁盘卷标 strType = String$(255, Chr$(0)) '文件系统类型 一般为 FAT R = GetVolumeInformation(sRoot, strLabel, Len(strLabel), _ lSerialNum, 0, 0, strType, Len(strType)) GetSerialNumber = lSerialNum '在 strLabel 中为 磁盘卷标 '在 strType 中为 文件系统类型 End Function用法:当驱动器不存在时,函数返回 0。如果是个非根目录,也将返回 0:lSerial = GetSerialNumber("c:\")
'Getcpuid.dll 获取的id只有8位,下面简短的代码返回的是16位16进制的字符串。'必须引用 Microsoft WMI Scripting Library Sub wmiProcessorID() Dim cpuSet As SWbemObjectSet Dim cpu As SWbemObject
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _ InstancesOf("Win32_Processor") For Each cpu In cpuSet MsgBox cpu.ProcessorId Next End Sub 网上的代码 我的cpu是AthlonXP2000+ 0383FBFF00000681序列号 各位测试一下看看!
东方热讯
从RING3获取硬盘序列号
Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, _
ByVal pVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long)
Private Const MAX_FILENAME_LEN = 256
Public Function DriveSerial(ByVal sDrv As String) As Long
'Usage:
'Dim ds As Long
'ds = DriveSerial("C")
Dim RetVal As Long
Dim str As String * MAX_FILENAME_LEN
Dim str2 As String * MAX_FILENAME_LEN
Dim a As Long
Dim b As Long
GetVolumeInformation sDrv & ":\", str, MAX_FILENAME_LEN, RetVal, _
a, b, str2, MAX_FILENAME_LEN
DriveSerial = RetVal
End Function
如果需要某个磁盘的序列号的话,只要DriveSerial(该磁盘的盘符)即可。
取得主板序列号的动态连接库及示例代码
磁盘序列号在每次软盘或硬盘格式化后都重新生成,并且不回重复。许多程序员用此加密。其实也可以修改该函数,可以得到磁盘卷标和文件系统类型信息。声明:
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(sRoot As String) As Long
Dim lSerialNum As Long
Dim R As Long
Dim strLabel As String, strType As String
strLabel = String$(255, Chr$(0))
'磁盘卷标
strType = String$(255, Chr$(0))
'文件系统类型 一般为 FAT
R = GetVolumeInformation(sRoot, strLabel, Len(strLabel), _
lSerialNum, 0, 0, strType, Len(strType))
GetSerialNumber = lSerialNum
'在 strLabel 中为 磁盘卷标
'在 strType 中为 文件系统类型
End Function用法:当驱动器不存在时,函数返回 0。如果是个非根目录,也将返回 0:lSerial = GetSerialNumber("c:\")
Sub wmiProcessorID() Dim cpuSet As SWbemObjectSet
Dim cpu As SWbemObject
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf("Win32_Processor")
For Each cpu In cpuSet
MsgBox cpu.ProcessorId
Next
End Sub
网上的代码
我的cpu是AthlonXP2000+ 0383FBFF00000681序列号
各位测试一下看看!