在代码最顶端添加Imports Scripting,在按钮的单击事件中加入以下代码: Imports Scripting Private Sub btnFso_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFso.Click Dim Fso As New FileSystemObject Dim drvDisk As Drive, strResult As String drvDisk = Fso.GetDrive("C:\") strResult = "Drive " & "C:\" & vbCrLf strResult += "磁盘卷标:" & drvDisk.VolumeName & vbCrLf strResult += "磁盘序列号:" & drvDisk.SerialNumber & vbCrLf strResult += "磁盘类型:" & drvDisk.DriveType & vbCrLf strResult += "文件系统:" & drvDisk.FileSystem & vbCrLf strResult += "磁盘容量(G): " & FormatNumber(((drvDisk.TotalSize / 1024) / 1024) / 1024, 2, , , Microsoft.VisualBasic.TriState.True) & vbCrLf strResult += "可用空间(G): " & FormatNumber(((drvDisk.FreeSpace / 1024) / 1024) / 1024, 2, , , Microsoft.VisualBasic.TriState.True) & vbCrLf strResult += "已用空间(G):" & FormatNumber(((((drvDisk.TotalSize - drvDisk.FreeSpace) / 1024) / 1024) / 1024), 2, , , Microsoft.VisualBasic.TriState.True) MsgBox(strResult) End Sub 3、用API函数GetVolumeInformation获取逻辑盘序列号 Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" _ (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal _ nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As Long, _ ByVal lpMaximumComponentLength As Integer, ByVal lpFileSystemFlags As Integer, ByVal _ lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Integer) As Integer |
正在阅读:VB.NET下获取硬盘信息的几种方法VB.NET下获取硬盘信息的几种方法
2004-03-11 10:00
出处:CSDN
责任编辑:linjixiong
键盘也能翻页,试试“← →”键