vb检查磁盘类型
Option Explicit Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Command1_Click() Select Case GetDriveType("C:\") Case 0 MsgBox "未知類型", vbExclamation Case 1 MsgBox "未知類型", vbCritical Case 2 MsgBox "可移動磁盤", vbInformation Case 3 MsgBox "本機磁盤", vbInformation Case 4 MsgBox "網絡磁盤", vbInformation Case 5 MsgBox "光驅", vbInformation Case 6 MsgBox "內存虛擬磁盤", vbInformation End Select End Sub 檢測有無移動磁盤插入 Option Explicit Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long Private Sub Command1_Click() If Ydcp() = False Then MsgBox "沒有檢測到移動磁盤" Else MsgBox "檢測到移動磁盤" End Sub Private Function Ydcp() As Boolean Dim i As Integer Ydcp = False For i = 65 To 90 If GetDriveType(Chr(i) & ":\") = 2 Then Ydcp = True Exit Function End If Next i End Function
Private Sub Command1_Click() Select Case GetDriveType("C:\") Case 0 MsgBox "未知類型", vbExclamation Case 1 MsgBox "未知類型", vbCritical Case 2 MsgBox "可移動磁盤", vbInformation Case 3 MsgBox "本機磁盤", vbInformation Case 4 MsgBox "網絡磁盤", vbInformation Case 5 MsgBox "光驅", vbInformation Case 6 MsgBox "內存虛擬磁盤", vbInformation End Select End Sub 檢測有無移動磁盤插入 Option Explicit Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long Private Sub Command1_Click() If Ydcp() = False Then MsgBox "沒有檢測到移動磁盤" Else MsgBox "檢測到移動磁盤" End Sub Private Function Ydcp() As Boolean Dim i As Integer Ydcp = False For i = 65 To 90 If GetDriveType(Chr(i) & ":\") = 2 Then Ydcp = True Exit Function End If Next i End Function
總結
- 上一篇: svn迁移到git
- 下一篇: UNDO Tablespace