用vb盘空间显示

来源:百度知道 编辑:UC知道 时间:2024/05/13 07:17:35
哪位哥门儿知道点击按钮就能在程序上显示U盘剩余的容量的代码和直接点击按钮就可打开我的电脑的方法,急求!

很简单,判断总线类型以及设备类型,得到USB闪盘和硬盘,然后可以用API获取容量,也可以用fso对象,具体的内容建议是自己动手查一下msdn,对于新手是一个必须经历的过程。

我写过一个usb助手,2.3版本的源码是公开的,可以到我的博客下载下来看看

打开我的电脑的方法,很简单,Shell "explorer"就可以了。

学习一下

Private Sub Form_Load()
Dim fso As New FileSystemObject
Dim driver As Drive
For Each driver In fso.Drives
If driver.IsReady Then
Label1.Caption = Label1.Caption & driver.DriveLetter & " FreeSpace:" & Format(driver.FreeSpace / 1024 / 1024, "#.00") & " MB" & vbCrLf
End If
Next driver
End Sub

'引用microsoft scripting runtime

===============

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Form_click()
ShellExecute Me.hwnd, "open", &quo