Private Sub Form_Load() Dim val As Integer GetCDRom End Sub 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 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 这样试一下
msgbox App.Path & "\setup2kxp.exe"
看看路径与2000下有什么不同你改成
Shell App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "setup2kxp.exe"
试一下。
因为你写的如果在根目录下就会有问题。
Dim val As Integer
GetCDRom
End Sub
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 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
这样试一下