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
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); SetSecurityDescriptorDacl(@sd, True, nil, False);
sa.nLength := SizeOf(TSecurityAttributes);
sa.bInheritHandle := True;
sa.lpSecurityDescriptor := @sd;
lpsa := @sa;
end;
Assert(CreatePipe(hReadPipe, hWritePipe, lpsa, 2500000));
GetStartupInfo(si);
si.cb := SizeOf(TStartupInfo);
si.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
si.wShowWindow := SW_HIDE;
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);
WaitForSingleObject(pi.hProcess, INFINITE);
Assert(Boolean(hReadPipe));
rdLoopDone := False;
FBreak := 1;
while not rdLoopDone do begin
FillChar(dest, SizeOf(dest), 0);
Assert(ReadFile(hReadPipe, dest, SizeOf(dest), LongWord(BytesRead), nil));
Sl.Add(String(dest));
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
Sl.SaveToFile('c:\1test.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