Ver Mensaje Individual
  #2  
Antiguo 07-09-2014
darkamerico darkamerico is offline
Miembro
 
Registrado: dic 2010
Posts: 273
Reputación: 16
darkamerico Va por buen camino
Red face Buscando insesantemente

Buscando incesantemente, finalmente un avance creo yo, el articulo aqui

Aquí el código que encontré:

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    function IsWindowsNT: Boolean;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
si: TStartupInfo;
pi: TProcessInformation;
sd: TSecurityDescriptor;
sa: TSecurityAttributes;
lpsa: PSecurityAttributes;
hReadPipe, hWritePipe : THandle;
BytesRead, FBreak: Integer;
dest: array [0..3999] of Char;
rdLoopDone: Boolean;
sl: TStringList;
i: Integer;
bShowHTML: Boolean;
begin
Memo1.Clear;
Sl := TStringList.Create;
lpsa := nil;
if (IsWindowsNT) then begin
InitializeSecurityDescriptor(@sd, 1); //Not sure what the value should be here - not running NT
SetSecurityDescriptorDacl(@sd, True, nil, False);
sa.nLength := SizeOf(TSecurityAttributes);
sa.bInheritHandle := True;
sa.lpSecurityDescriptor := @sd;
lpsa := @sa;
end;

//We create a pipe here to pass the DOS output to
Assert(CreatePipe(hReadPipe, hWritePipe, lpsa, 2500000));
GetStartupInfo(si);
si.cb := SizeOf(TStartupInfo);
si.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
si.wShowWindow := SW_HIDE;

//The write handle is asigned to the startupinfo record so CreateProcess knows
//where to send the output
si.hStdOutput := hWritePipe;
si.hStdError := hWritePipe;
Assert(Boolean(hWritePipe));

Assert(CreateProcess(nil, 'c:\xampp\php\php.exe d:\script.php scriptparameter=value', nil, nil, True, 0, nil, nil, si, pi));
CloseHandle(pi.hThread);

//Let's wait for the DOS app to finish
WaitForSingleObject(pi.hProcess, INFINITE);
Assert(Boolean(hReadPipe));
rdLoopDone := False;
FBreak := 1;

//And now read the data from the pipe and add it to our RichEdit control
while not rdLoopDone do begin
FillChar(dest, SizeOf(dest), 0);
Assert(ReadFile(hReadPipe, dest, SizeOf(dest), LongWord(BytesRead), nil));
// Save each output line to a stringlist
Sl.Add(String(dest));
// and print it to a memo
Memo1.Lines.Text := Memo1.Lines.Text + String(dest);
if (BytesRead < 4000) then
rdLoopDone := True;
if (FBreak > 150) then
rdLoopDone := True;
Inc(FBreak);
end;
for i := 0 to Pred(sl.Count) do
if Pos('Content-type: text/html', sl.Strings[i]) > 0 then
bShowHtml := True;
if bShowHTML then
begin
// This saves the output to HTML FIle
Sl.SaveToFile('c:\1test.html');
// and now navigates TWebbrowser to the outputed HTML
WebBrowser1.Navigate('c:\1test.html');
end;
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
CloseHandle(pi.hProcess);
end;

function TForm1.IsWindowsNT: Boolean;
var
  osv: TOsVersionInfo;
begin
  osv.dwOSVersionInfoSize := SizeOf(osv);
  GetVersionEx(osv);
  Result := (osv.dwPlatformId = VER_PLATFORM_WIN32_NT);
end;

end.

El error aparece en la línea:

Código Delphi [-]
Assert(ReadFile(hReadPipe, dest, SizeOf(dest), LongWord(BytesRead), nil));

Por favor ayuda, se que estoy cerca.

Gracias
Responder Con Cita