例如:
有一个文件是run.exe,我将其他更名为run.x86,如何让VB直接执行run.x86这个文件呢?我经常看到taskmgr里有一些执行程序都是xxx.dat之类的,不知道如何办到。望赐教,万分感激。

解决方案 »

  1.   

    试一试
    Public 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 Long
    Private Sub Command1_Click()
    rt = ShellExecute(Me.hwnd, "open", "C:\run.x86", "", "", SW_SHOWNORMAL)
    End Sub
      

  2.   

    非exe可执行文件一般可用ShellExecute这一API打开
      

  3.   

    对于可执行文件,只要可以被装入,其后缀名是什么并不重要.直接用createprocess建立进程即可.以下例子,是将notepad.exe复制到D:\根目录,并改名为notepad.xls来测试的:'窗体中添加一个按钮,名称默认.
    Option ExplicitPrivate Type PROCESS_INFORMATION
        hProcess As Long
        hThread As Long
        dwProcessId As Long
        dwThreadId As Long
    End Type
    Private Type STARTUPINFO
        cb As Long
        lpReserved As String
        lpDesktop As String
        lpTitle As String
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Byte
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
    End Type
    Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" ( _
                ByVal lpApplicationName As String, _
                ByVal lpCommandLine As String, _
                ByVal lpProcessAttributes As Long, _
                ByVal lpThreadAttributes As Long, _
                ByVal bInheritHandles As Long, _
                ByVal dwCreationFlags As Long, _
                ByVal lpEnvironment As Long, _
                ByVal lpCurrentDriectory As String, _
                lpStartupInfo As STARTUPINFO, _
                lpProcessInformation As PROCESS_INFORMATION) As LongPrivate Sub Command1_Click()
        Dim lRet As Long, Si As STARTUPINFO, Pi As PROCESS_INFORMATION
        
        Si.cb = LenB(Si)
        lRet = CreateProcess("d:\notepad.xls", vbNullString, 0&, 0&, 0&, 0&, 0&, vbNullString, Si, Pi)
        Debug.Print lRet; Err.LastDllError
    End Sub
    收分走人............
      

  4.   

    只有在WINDOWS下才是用后缀来判断的
     程序里是通过文件头来判断的