Hallo an Alle,
komme mit meinem Problem nicht weiter, deshalb nochmal ein Hilferuf von mir.
Die Java-Anwendung kann ich nicht ändern.
Hier aber der Source, für ein einfaches Formular, mit Command-Button:
Option Explicit
Private Sub Command1_Click()
Dim I As Long
Dim ret As Long
Dim hErrRead As Long
Dim hErrWrite As Long
Dim hReadPipe1 As Long ' STDOUT
Dim hWritePipe1 As Long ' STDOUT
Dim hReadPipe2 As Long ' STDERR
Dim hWritePipe2 As Long ' STDERR
Dim hReadPipe3 As Long ' STDIN
Dim hWritePipe3 As Long ' STDIN
Dim bytewritten As Long
Dim cmdline As String
Dim StuffToWrite As String
Dim start As STARTUPINFO
Dim proc As PROCESS_INFORMATION
start.cb = Len(start)
' A pipe of redirection of STDOUT
ret = CreatePipe(hReadPipe1, hWritePipe1, 0&, 0&)
If ret = 0 Then MsgBox "Konnte Pipe STDOUT nicht öffnen: " & Err.LastDllError
' A pipe of redirection of STDERR
ret = CreatePipe(hReadPipe2, hWritePipe2, 0&, 0&)
If ret = 0 Then MsgBox "Konnte Pipe STDERR nicht öffnen: " & Err.LastDllError
' A pipe of redirection of STDIN
ret = CreatePipe(hReadPipe3, hWritePipe3, 0&, 0&)
If ret = 0 Then MsgBox "Konnte Pipe STDIN nicht öffnen: " & Err.LastDllError
start.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW
'start.dwFlags = STARTF_USESTDHANDLES
start.hStdOutput = hWritePipe1
start.hStdError = hWritePipe2
start.hStdInput = hReadPipe3
cmdline$ = "java -cp c:\programme\jet\bin\bsh-1.3.0.jar bsh.Interpreter"
'cmdline$ = "D:\VC\VC.COM"
ret = CreateProcess(0&, cmdline$, 0&, 0&, True, &H20, 0&, 0&, start, proc)
If ret = 0 Then
MsgBox "Anwendung kann nicht gestartet werden: " & Err.LastDllError, _
vbCritical, "BeanShell 1.3"
End If
' Folgende Übergaben müssen nacheinander in einer Schleife abgearbeitet werden
' und sollten in Java ein Fenster öffnen
For I = 1 To 4
DoEvents
Select Case I
Case 1
StuffToWrite = "JFrame frame = new JFrame();" & Chr$(13)
Case 2
StuffToWrite = "frame.setSize(200,200);" & Chr$(13)
Case 3
StuffToWrite = "frame.show();" & Chr$(13)
Case 4
StuffToWrite = "frame.toFront();" & Chr$(13)
End Select
' Send it.
ret = WriteFile(hWritePipe3, StuffToWrite, Len(StuffToWrite), bytewritten, _
CLng(0))
If ret = 0 Then
MsgBox "Anwendung wurde nicht beschrieben: " & Err.LastDllError
Else
MsgBox "Anzahl übergebene Zeichen: " & bytewritten
End If
Next I
ret = TerminateProcess(proc.hProcess, 0&)
If ret = 0 Then
MsgBox "Process wurde nicht ordnungsgemäß beendet: " & Err.LastDllError
Else
DoEvents
End If
CloseHandle hReadPipe1
CloseHandle hWritePipe1
CloseHandle hReadPipe3
CloseHandle hWritePipe3
End Sub BasTler |