求高手帮忙写一个简单的vb程序
来源:百度知道 编辑:UC知道 时间:2024/05/16 04:15:04
这是一个vb的程序,可以完成楼主的要求!
Option Explicit
Private Const DRIVE_REMOVABLE = 2
Private Const DRIVE_FIXED = 3
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_CDROM = 5
Private Const DRIVE_RAMDISK = 6
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
Form1.Hide
Form1.Icon = 0
Dim ntype As Long, S As String, sDrive As String
Dim pos As Integer
S = String(256, Chr(0))
GetLogicalDriveStrings Len(S), S
Do
pos = InStr(S, Chr(0))
sDrive = Left(S, pos - 1)
If Len(sDrive) = 0 Then Exit Do
S = Mid(S, pos + 1)