我写的程序要放在光盘上,光盘放进去后会自动运行该程序,怎么样才能用获取该光盘所在的盘符呢?应该比较简单吧?小弟谢谢先了
Option Explicit
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Const DRIVE_CDROM = 5
Private Sub Command1_Click()
   Dim i As Integer
   Dim DriveStrings As String
   Dim nBuffer As String * 200
   Dim GetDrive As Long
   Dim DriveType As Long
   GetDrive = GetLogicalDriveStrings(Len(nBuffer), nBuffer)
   For i = 1 To Len(nBuffer)
       DriveStrings = Mid$(nBuffer, i, 1)
       If DriveStrings >= "A" And DriveStrings <= "Z" Then
            'Print DriveStrings
            DriveType = GetDriveType(DriveStrings & ":\")
            If DriveType = DRIVE_CDROM Then
                 MsgBox "你的CD_ROM是" & DriveStrings & "盘"
            End If
       End If
   Next
End Sub



											
	    

	

