獲取序列號是要讀取軟硬光盤的信息,可通過以下函數獲得:
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("盤符")就可以了!
這樣就可以十分順利的來控制鼠標了!