可以,只要有一个程序是你做的就行Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Const STATUS_PENDING = &H103& Private Const PROCESS_QUERY_INFORMATION = &H400Private Function RunShell(cmdline As String, Index As Integer) As Boolean Dim hProcess As Long Dim ProcessID As Long Dim ExitCodeLong As Long Dim str1 As String Me.Hide ProcessID = Shell(cmdline, vbNormalFocus) hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID) If hProcess = 0 Then Select Case Index Case 0 MsgBox "无法启动输出分析平台", vbInformation, MyTitle Case 1 MsgBox "无法启动物理解读平台", vbInformation, MyTitle Case 2 MsgBox "无法启动研究试验平台", vbInformation, MyTitle Case 3 MsgBox "无法启动Micaps程序", vbInformation, MyTitle End Select End If Do Call GetExitCodeProcess(hProcess, ExitCodeLong) DoEvents Loop While ExitCodeLong = STATUS_PENDING Call CloseHandle(hProcess) RunShell = True Me.Show End Function
上面的是我的程序 Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Const STATUS_PENDING = &H103& Private Const PROCESS_QUERY_INFORMATION = &H400Private Function RunShell(cmdline As String) As Boolean Dim hProcess As Long Dim ProcessID As Long Dim ExitCodeLong As Long Dim str1 As String Me.Hide ProcessID = Shell(cmdline, vbNormalFocus) hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID) Do Call GetExitCodeProcess(hProcess, ExitCodeLong) DoEvents Loop While ExitCodeLong = STATUS_PENDING Call CloseHandle(hProcess) RunShell = True Me.Show End Function
【VB声明】 Private Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long【说明】 将窗口设为系统的前台窗口。这个函数可用于改变用户目前正在操作的应用程序 【返回值】 Long,非零表示成功,零表示失败。会设置GetLastError 【备注】 不应随便使用它,因为一旦程序突然从后台进入前台,可能会使用户产生迷惑【参数表】 hwnd ----------- Long,带到前台的窗口
等那个程序运行完后,才切换回原来的程序。
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const STATUS_PENDING = &H103&
Private Const PROCESS_QUERY_INFORMATION = &H400Private Function RunShell(cmdline As String, Index As Integer) As Boolean
Dim hProcess As Long
Dim ProcessID As Long
Dim ExitCodeLong As Long
Dim str1 As String
Me.Hide
ProcessID = Shell(cmdline, vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID)
If hProcess = 0 Then
Select Case Index
Case 0
MsgBox "无法启动输出分析平台", vbInformation, MyTitle
Case 1
MsgBox "无法启动物理解读平台", vbInformation, MyTitle
Case 2
MsgBox "无法启动研究试验平台", vbInformation, MyTitle
Case 3
MsgBox "无法启动Micaps程序", vbInformation, MyTitle
End Select
End If
Do
Call GetExitCodeProcess(hProcess, ExitCodeLong)
DoEvents
Loop While ExitCodeLong = STATUS_PENDING
Call CloseHandle(hProcess)
RunShell = True
Me.Show
End Function
Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const STATUS_PENDING = &H103&
Private Const PROCESS_QUERY_INFORMATION = &H400Private Function RunShell(cmdline As String) As Boolean
Dim hProcess As Long
Dim ProcessID As Long
Dim ExitCodeLong As Long
Dim str1 As String
Me.Hide
ProcessID = Shell(cmdline, vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID)
Do
Call GetExitCodeProcess(hProcess, ExitCodeLong)
DoEvents
Loop While ExitCodeLong = STATUS_PENDING
Call CloseHandle(hProcess)
RunShell = True
Me.Show
End Function
Private Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long【说明】
将窗口设为系统的前台窗口。这个函数可用于改变用户目前正在操作的应用程序 【返回值】
Long,非零表示成功,零表示失败。会设置GetLastError 【备注】
不应随便使用它,因为一旦程序突然从后台进入前台,可能会使用户产生迷惑【参数表】
hwnd ----------- Long,带到前台的窗口