Tal vez si conocen el código que estoy usando sea más fácil para ustedes entender mi problema. el código es el siguiente:
Código Delphi
[-]procedure TForm1.PostKeyEx32(key: Word; const shift: TShiftState; specialkey: Boolean);
Type
TShiftKeyInfo = Record
shift: Byte;
vkey : Byte;
End;
byteset = Set of 0..7;
Const
shiftkeys: Array [1..3] of TShiftKeyInfo =
((shift: Ord(ssCtrl); vkey: VK_CONTROL ),
(shift: Ord(ssShift); vkey: VK_SHIFT ),
(shift: Ord(ssAlt); vkey: VK_MENU ));
Var
flag: DWORD;
bShift: ByteSet absolute shift;
i: Integer;
Begin
For i := 1 To 3 Do Begin
If shiftkeys[i].shift In bShift Then
keybd_event( shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), 0, 0);
End;
If specialkey Then
flag := KEYEVENTF_EXTENDEDKEY
Else
flag := 0;
keybd_event( key, MapvirtualKey( key, 0 ), flag, 0 );
flag := flag or KEYEVENTF_KEYUP;
keybd_event( key, MapvirtualKey( key, 0 ), flag, 0 );
For i := 3 DownTo 1 Do Begin
If shiftkeys[i].shift In bShift Then
keybd_event( shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), KEYEVENTF_KEYUP, 0);
End;
End;
function TForm1.WinExecAndWait32(FileName: String; Visibility: Integer): Integer;
var
zAppName: Array[0..512] of Char;
zCurDir: Array[0..255] of Char;
WorkDir: String;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
Resultado, ExitCode: DWord;
begin
StrPCopy(zAppName, FileName);
GetDir(0, WorkDir);
StrPCopy(zCurDir, WorkDir);
FillChar(StartupInfo, Sizeof(StartupInfo), #0);
StartupInfo.cb := SizeOf(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
CreateProcess(nil, zAppName, nil, nil, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,
nil, nil, StartupInfo, ProcessInfo);
repeat
exitCode := WaitForSingleObject(ProcessInfo.hProcess,1000);
Application.ProcessMessages;
until (exitCode <> WAIT_OBJECT_0);
GetExitCodeProcess(ProcessInfo.hProcess,Resultado);
MessageBeep(0);
CloseHandle(ProcessInfo.hProcess);
Result := Resultado;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
F: TextFile;
H: HWND;
I, J: Integer;
C: Char;
Genoma: Array of Char;
begin
WinExecAndWait32(PChar('C:\VIENNA\RNAfold.exe'),SW_SHOWNORMAL);
for J := 1 to 1443 do
begin
AssignFile(F, 'C:\GenomasGenerados\SinGenes\' + IntToStr(J) + '\GenomaInicial.txt');
try
Reset(F);
except
CloseFile(F);
Exit;
end;
SetLength(Genoma, 0);
while not Eof(F) do
begin
Read(F, C);
SetLength(Genoma, Length(Genoma) + 1);
Genoma[High(Genoma)] := C;
end;
CLoseFile(F);
H := FindWindow(Nil,'C:\VIENNA\RNAfold.exe');
if H = 0 then ShowMessage('No se encontro la Aplicacion')
else
begin
SetForegroundWindow(H);
for I := Low(Genoma) to High(Genoma) do
PostKeyEx32(Ord(Genoma[i]), [], False);
repeat
Application.ProcessMessages;
until FileExists('C:\Erika\ICBME\Delphi y Vienna\rna.ps');
end;;
LeerPantallaRNAFold
end;
H := FindWindow(Nil,'C:\VIENNA\RNAfold.exe');
if H = 0 then ShowMessage('No se encontro la Aplicacion');
SendMessage(H, WM_CLOSE, 0, 0);
end;
y lo que no puedo hacer es capturar los datos de salida que me da la aplicación rnafold.exe. Esta salida es de tipo stdout, es decir no me genera ningún archivo de salida.
Gracias por su ayuda!!!