可以啊,我在VB中是这样做的:
Public Sub Run(StrExePath As String) '调用一个EXE文件,如果该文件已经存在,则激活它
Dim Res As Integer
Dim FileName As String
Dim StrCurrentDir As String
Dim IntPathLng As Integer
On Error GoTo Err_Handler
FileName = Dir(StrExePath)
IntPathLng = Len(StrExePath) - Len(FileName) - 1
StrCurrentDir = Left(StrExePath, IntPathLng)
'Res = Shell(StrExePath, vbNormalFocus) Shell函数无法设定EXE文件的运行起始路径,因此改用API函数ShellExecute
Res = ShellExecute(UserControl.hwnd, "open", StrExePath, (GcCode &
"
"
&
DocType &
"
83"
, StrCurrentDir, SW_SHOW + SW_RESTORE)
If Res < 32 Then Err.Raise 12345 + vbObjectError, App.EXEName, "调用可执行文件错误"
Exit Sub
Err_Handler:
Dim StrPrompt As String
StrPrompt = "系统调用失败(没有找到可执行文件)。"
&
vbCrLf
MsgBox StrPrompt
End Sub
Private Sub UserControl_Initialize()
NoError = True
GcCode = ""
DocType = ""
End Sub