用SHELLEXECUTE这个API函数或者用shell函数

解决方案 »

  1.   

    ShellExecute MainFrm.hwnd, "Open", str, 0&, 0&, 6
    就可以了,其中str不一定要是可执行文件,例如doc文档也可以,都可以自动关联打开
    把分数给我吧
      

  2.   

    ShellExecute MainFrm.hwnd, "Open", str, 0&, 0&, 6
    就可以了,其中str不一定要是可执行文件,例如doc文档也可以,都可以自动关联打开
    把分数给我吧
      

  3.   

    ShellExecute是Api函数,有点麻烦,我给个简单的,shell函数,shell("要执行的文件名",程序执行的方式),在Vb中敲入shell(,系统就会给出参数提示。
      

  4.   

    Shell与ShellExecute都可以,不过,你要是想调用与某文件相关联的EXE的话,请用ShellExecute。
      

  5.   

    用shell!
    通过带一些参数,可以使屏幕出现或不出现执行窗口。
    另外通过其他函数可以一直探测执行外部程序的情况。
      

  6.   

    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 LongFunction Shell(Program As String, Optional ShowCmd As Long = vbNormalNoFocus, Optional ByVal WorkDir As Variant) As Long    Dim FirstSpace As Integer, Slash As Integer
        If Left(Program, 1) = """" Then
            FirstSpace = InStr(2, Program, """")
            If FirstSpace <> 0 Then
                Program = Mid(Program, 2, FirstSpace - 2) & Mid(Program, FirstSpace + 1)
                FirstSpace = FirstSpace - 1
            End If    Else
            FirstSpace = InStr(Program, " ")
        End If    If FirstSpace = 0 Then FirstSpace = Len(Program) + 1
        If IsMissing(WorkDir) Then
            For Slash = FirstSpace - 1 To 1 Step -1
                If Mid(Program, Slash, 1) = "\" Then Exit For
            Next        If Slash = 0 Then
                WorkDir = CurDir
            ElseIf Slash = 1 Or Mid(Program, Slash - 1, 1) = ":" Then
                WorkDir = Left(Program, Slash)
            Else
                WorkDir = Left(Program, Slash - 1)
            End If    End If    Shell = ShellExecute(0, vbNullString, _
        Left(Program, FirstSpace - 1), LTrim(Mid(Program, FirstSpace)), _
        WorkDir, ShowCmd)
        If Shell < 32 Then VBA.Shell Program, ShowCmd 'To raise Error
    End Function
    Call Shell(filename)   ' filename 为所调用文件 路径,什么文件都可以打开 ,filename为字符型变量