主题:调用EXE文件无法输出文
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Option Explicit
Private Sub Command1_Click()
Dim ProcessId As Long
ProcessId = Shell("E:\Console2\Debug\Console1.exe", 1)
'启动FORTRAN 计算程序,并隐藏DOS 窗口
Do While StillRun(ProcessId)
'调用StillRun 函数监视外部程序Console1. exe 的运行状态
DoEvents
Loop
End Sub
Public Function StillRun(ByVal ProcessId) As Boolean
'定义一个判断外壳程序运行状态的函数
Dim HProgram As Long
'ProgramID 是Shell 函数的返回值(即外部程序的进程号)
HProgram = OpenProcess(0, False, ProcessId)
'返回被测程序的句柄hProgram
If Not HProgram = 0 Then '外部程序还在运行
StillRun = True
Else '外部程序运行结束
StillRun = False
End If
CloseHandle (HProgram)
End Function
我用这个程序调用一个EXE文件,但是最后不会生成输出文件,请问问题出在哪呀?
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Option Explicit
Private Sub Command1_Click()
Dim ProcessId As Long
ProcessId = Shell("E:\Console2\Debug\Console1.exe", 1)
'启动FORTRAN 计算程序,并隐藏DOS 窗口
Do While StillRun(ProcessId)
'调用StillRun 函数监视外部程序Console1. exe 的运行状态
DoEvents
Loop
End Sub
Public Function StillRun(ByVal ProcessId) As Boolean
'定义一个判断外壳程序运行状态的函数
Dim HProgram As Long
'ProgramID 是Shell 函数的返回值(即外部程序的进程号)
HProgram = OpenProcess(0, False, ProcessId)
'返回被测程序的句柄hProgram
If Not HProgram = 0 Then '外部程序还在运行
StillRun = True
Else '外部程序运行结束
StillRun = False
End If
CloseHandle (HProgram)
End Function
我用这个程序调用一个EXE文件,但是最后不会生成输出文件,请问问题出在哪呀?