读取软硬光盘序列号

类别:VB语言 点击:0 评论:0 推荐:

 

读取软硬光盘序列号

获取序列号是要读取软硬光盘的信息,可通过以下函数获得:
Public 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 GetItNum(strDrv As String) As Long
Dim GetNum As Long
Dim Rs As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Rs = GetVolumeInformation(strDrv, Temp1, Len(Temp1), GetNum, 0, 0, Temp2, Len(Temp2))
MsgBox "卷标为:"+Temp1
MsgBox "序列号为:"+Hex(SerialNum)
End Function
以后使用时就调用GetItNum("盘符")就可以了!
这样就可以十分顺利的来控制鼠标了!

本文地址:http://com.8s8s.com/it/it6657.htm