下面有一个是VB写的获取硬盘序列号的代码: 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 Private Sub Command1_Click() Dim mySerial As Long Dim mylong As Long mystr = String$(255, Chr$(0)) mytype = String$(255, Chr$(0)) If Right(Text1.Text, 1) <> "\" Then Text1.Text = Text1.Text & "\" sRoot = Text1.Text '设定盘名 mylong = GetVolumeInformation(sRoot, mystr, Len(mystr), mySerial, 0, 0, mytype, Len(mytype)) Text2.Text = mySerial 'TEXT2 存放盘序列号 End Sub Private Sub Command3_Click() End End Sub |