关于 VB.NET 2008中U盘的插拔一下代码将自动完成检测:
Imports System.IO
Public Class Form1
Public Const WM_DEVICECHANGE = H219
Public Const DBT_DEVICEARRIVAL = H8000
Public Const DBT_DEVICEREMOVECOMPLETE = H8004
Dim DriveLetter As String
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_DEVICECHANGE Then
Select Case m.WParam
Case DBT_DEVICEARRIVAL
Dim s() As DriveInfo = DriveInfo.GetDrives
For Each drive As DriveInfo In s
If drive.DriveType = DriveType.Removable Then
DriveLetter = drive.Name.ToString()
Debug.WriteLine("U盘 :"DriveLetter"已插入.")
End If
Next
Case DBT_DEVICEREMOVECOMPLETE
Dim s() As DriveInfo = DriveInfo.GetDrives
For Each drive As DriveInfo In s
If drive.ToString = DriveLetter Then Exit Sub
Next
Debug.WriteLine("U盘:"DriveLetter"已卸载!")
【vb.net磁盘卷标 磁盘卷标dos命令】End Select
End If
MyBase.WndProc(m)
End Sub
End Class
Vb如何获取系统卷标磁盘名字各是什么? 急求,谢啦添加对应DriveListBox控件
代码如下:
n = Drive1.ListCount
For i = 0 To n - 1
Drive1.ListIndex = i
DrvName = Left(Drive1.Drive, 2)'这是盘符名
DrvLabel = Mid(Drive1.Drive, 3, Len(Drive1.Drive) - 2) '这是卷标名
'需要说明的是:卷标名如果为默认名称,读到是空的,可加个if显示为“本地磁盘”
Print DrvName, DrvLabel
Next i
需要帮忙,向我求助好了~两页一答!
vb.net如何获取电脑中的所有盘符首先使用 System.IO.DriveInfo.GetDrives()获取System.IO.DriveInfovb.net磁盘卷标,存入ds()
然后遍历dsvb.net磁盘卷标,获取各个信息部分 。
Dim ds() As System.IO.DriveInfo = System.IO.DriveInfo.GetDrives()
For i As Integer = 0 To ds.Length - 1
TextBox1.Text = TextBox1.Textds(i).DriveType.ToString" " '驱动器类型
TextBox1.Text = TextBox1.Textds(i).Name" " '盘符(驱动器名)
TextBox1.Text = TextBox1.Textds(i).IsReady.ToString" " '是否就绪
If ds(i).IsReady = True Then
TextBox1.Text = TextBox1.Textds(i).VolumeLabel" " '卷标
TextBox1.Text = TextBox1.Textds(i).TotalSize.ToString" " '驱动器容量
TextBox1.Text = TextBox1.Textds(i).TotalFreeSpace.ToString '驱动器可用容量
End If
TextBox1.Text = TextBox1.TextvbNewLine
Next
vb.net磁盘卷标的介绍就聊到这里吧 , 感谢你花时间阅读本站内容 , 更多关于磁盘卷标dos命令、vb.net磁盘卷标的信息别忘了在本站进行查找喔 。
推荐阅读
- wordpress微信服务号,WordPress微信小程序
- 区块链形状特点有,区块链的典型特征有哪些
- 包含1加2分之1java代码的词条
- 幸福街电商如何经营,幸福电商园
- ios系统已下载怎么删掉,ios系统学习
- 直播带货上岗北京,北京直播带货公司排名榜
- 关于windows系统淘汰的信息
- 升级鸿蒙系统后注意,升级鸿蒙系统之后
- 关于谷歌新系统fuchsiaflutter的信息