Private Declare Function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dsProcessId 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 Long Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As _ String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _ ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As String, _ ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) _ As Long Private Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String 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 Type Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Private Const PROCESS_QUERY_INFORMATION = &H400& Private Const STILL_ACTIVE = &H103& Public Function ProcessExec(ByRef command As String, ByRef path As String) As Long Dim ret As Long Dim StartInfo As STARTUPINFO Dim ProcInfo As PROCESS_INFORMATION Dim cmdLine As String cmdLine = path & "\" & command StartInfo.cb = Len(StartInfo) ret = CreateProcess(vbNullString, cmdLine, 0&, 0&, _ 0&, 0, vbNullString, path, StartInfo, ProcInfo) ProcessExec = ProcInfo.dwProcessId End Function Public Function ProcessWait(id As Long) As Long Dim hProcess As Long, ExitCode As Long Dim ret As Long hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 1, id) Do ret = GetExitCodeProcess(hProcess, ExitCode) DoEvents Loop While (ExitCode = STILL_ACTIVE) ret = CloseHandle(hProcess) ProcessWait = ExitCode End Function ' 変換が正常に終了したら、その内容を表示する。 ' Private Sub Command1_Click() On Error GoTo Err_Command1_Click Dim IDProcess As Long, ExitCode As Long Dim path As String ' カレントディレクトリをF*TRAN+のインストールディレクトリに設定する path = "c:\FtranP" ' インストールディレクトリ ChDrive "c" ' インストールドライブ ChDir path ' カレントディレクトリにあるサンプルファイル「planet」をデータファイル変換する。 IDProcess = ProcessExec("fp.exe /nwd /wc/ getdata planet *.txt ++pngetprn.p", path) ExitCode = ProcessWait(IDProcess) Open "planet.txt" For Input As #1 Close #1 Call Shell("command.com /K type planet.txt", vbNormalFocus) ' NTではcmd.exeを使用する。 Exit_Command1_Click: Exit Sub Err_Command1_Click: MsgBox Err.Description Resume Exit_Command1_Click End Sub Private Sub Command2_Click() End End Sub