当前位置:编程学习 > VB >>

请教vb高手关于vb程序调用FORTRAN可执行文件的问题!

Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Sub Command1_Click()
    Dim RetVal
    RetVal = Shell(App.Path & "\" & "HalfDis.exe", vbMinimizedNoFocus)
    Do While IsRunning(RetVal)
        DoEvents
    Loop
    MsgBox "调用结束"
End Sub

Private Function IsRunning(ByVal ProgramID) As Boolean    '传入进程标识ID

    Dim hProgram As Long     '被检测的程序进程句柄
    hProgram = OpenProcess(0, False, ProgramID)
    If Not hProgram = 0 Then
     IsRunning = True
    Else
     IsRunning = False
    End If
    CloseHandle hProgram
End Function


程序代码如上,所调用HalfDis.exe文件为fortran编译,其中HalfDis.exe中需要读取和保存文本文件,而vb执行时,找不到需要读取和保存文本文件的路径,
出现run-time error f6416:open<.\indata\tqpelv.tex>-file not found错误
本人研究了几天,未能解决,恳请各位高手帮忙 --------------------编程问答-------------------- 把你的可执行文件做成DLL就可以了,在VB中直接调用该函数。
补充:VB ,  资源
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,