Option ExplicitPrivate Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long Private Declare Function GetLogicalDrives Lib "kernel32" () As Long 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 LongConst SW_SHOWNORMAL = 1Private Function IsCDRom(ByVal sDriver As String) As Boolean Select Case GetDriveType(sDriver) Case 2: IsCDRom = False 'Me.Print "Removable" Case 3: IsCDRom = False ' Me.Print "Drive Fixed" Case Is = 4: IsCDRom = False ' Me.Print "Remote" Case Is = 5: IsCDRom = True ' Me.Print "Cd-Rom" Case Is = 6: IsCDRom = False ' Me.Print "Ram disk" Case Else: IsCDRom = False ' Me.Print "Unrecognized" End Select End Function Private Function GetCDRom() As String Dim LDs As Long, Cnt As Long, sDriver As String LDs = GetLogicalDrives For Cnt = 0 To 25 If (LDs And 2 ^ Cnt) <> 0 Then sDriver = Chr$(65 + Cnt) & ":\" If IsCDRom(sDriver) Then Run sDriver End If End If Next Cnt End FunctionPrivate Sub Run(ByVal sDriver As String) Dim sFile As String sFile = sDriver & "a.txt" 'a.txt换成你的可执行文件名 If Dir(sFile) <> "" Then MsgBox "Goin' to run " & sFile & "!": ShellExecute Me.hwnd, vbNullString, sFile, vbNullString, vbNullString, SW_SHOWNORMALEnd SubPrivate Sub Form_Load() GetCDRom End Sub你再重新试一边,把以上的代码完整复制到工程里面 自己多看看,分析分析,不要总是指望别人,多看看帮助队你自己有好处
Private Declare Function GetLogicalDrives Lib "kernel32" () As Long
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 LongConst SW_SHOWNORMAL = 1Private Function IsCDRom(ByVal sDriver As String) As Boolean
Select Case GetDriveType(sDriver)
Case 2: IsCDRom = False 'Me.Print "Removable"
Case 3: IsCDRom = False ' Me.Print "Drive Fixed"
Case Is = 4: IsCDRom = False ' Me.Print "Remote"
Case Is = 5: IsCDRom = True ' Me.Print "Cd-Rom"
Case Is = 6: IsCDRom = False ' Me.Print "Ram disk"
Case Else: IsCDRom = False ' Me.Print "Unrecognized"
End Select
End Function
Private Function GetCDRom() As String
Dim LDs As Long, Cnt As Long, sDriver As String
LDs = GetLogicalDrives
For Cnt = 0 To 25
If (LDs And 2 ^ Cnt) <> 0 Then
sDriver = Chr$(65 + Cnt) & ":\"
If IsCDRom(sDriver) Then
Run sDriver
End If
End If
Next Cnt
End FunctionPrivate Sub Run(ByVal sDriver As String)
Dim sFile As String
sFile = sDriver & "a.txt" 'a.txt换成你的可执行文件名
If Dir(sFile) <> "" Then MsgBox "Goin' to run " & sFile & "!": ShellExecute Me.hwnd, vbNullString, sFile, vbNullString, vbNullString, SW_SHOWNORMALEnd SubPrivate Sub Form_Load()
GetCDRom
End Sub你再重新试一边,把以上的代码完整复制到工程里面
自己多看看,分析分析,不要总是指望别人,多看看帮助队你自己有好处
你可以看dll的接口含数dependence.exe