自启动程序?
在SUB MAIN()中先调用自启动程序(有模式),然后再自启动运行的时候LOAD 需要启动的程序,等LOAD(注意,不是show)结束以后,卸载自启动窗体。

解决方案 »

  1.   

    我想我没有说清楚,是这样的。
    现在有两个.exe文件,如1.exe和2.exe
    启动1.exe的时候关闭2.exe文件(两个不同时运行,有冲突)
    关闭1.exe的时候自动把前面关闭的2.exe文件启动起来。
    1.exe和2.exe是别人写好了的。
      

  2.   

    看這個吧~ :)' 聲明:
    Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As Long, 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 Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As LongPrivate Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPrivate Type PROCESS_INFORMATION
        hProcess As Long
        hThread As Long
        dwProcessId As Long
        dwThreadId As Long
        End TypePrivate Type STARTUPINFO
        cb As Long
        lpReserved As Long
        lpDesktop As Long
        lpTitle As Long
        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 Long
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
        End TypePrivate Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As LongFunction ShellAndWait(strCommandLine As String, lWait As Long) As Long
        Dim objProcess As PROCESS_INFORMATION
        Dim objStartup As STARTUPINFO
        Dim lResult As Long
        Dim lExitCode As Long
        
        objStartup.cb = 68
        objStartup.lpReserved = 0
        objStartup.lpDesktop = 0
        objStartup.lpTitle = 0
        objStartup.dwX = 0
        objStartup.dwY = 0
        objStartup.dwXSize = 0
        objStartup.dwYSize = 0
        objStartup.dwXCountChars = 0
        objStartup.dwYCountChars = 0
        objStartup.dwFillAttribute = 0
        objStartup.dwFlags = 0
        objStartup.wShowWindow = 0
        objStartup.cbReserved2 = 0
        objStartup.lpReserved2 = 0
        objStartup.hStdInput = 0
        objStartup.hStdOutput = 0
        objStartup.hStdError = 0
        
        lResult = CreateProcess(0, strCommandLine, 0, 0, 0, 0, 0, 0, objStartup, objProcess)
        If lResult = 0 Then
            ShellAndWait = -1
            Exit Function
        End If
            If lWait <> 0 Then
            lResult = WaitForSingleObject(objProcess.hProcess, lWait)
            If lResult = 258 Then
                lResult = TerminateProcess(objProcess.hProcess, -1)
                lResult = WaitForSingleObject(objProcess.hProcess, lWait)
            End If
        End If
        
        lResult = GetExitCodeProcess(objProcess.hProcess, lExitCode)
        lResult = CloseHandle(objProcess.hProcess)
        lResult = CloseHandle(objProcess.hThread)
        
        ShellAndWait = lExitCode
    End Function