Доброго времени суток!
Скачал архив с php интерпертатором, с официального сайта.
Передаю через командную строку имя php скрипта через delphi,
для выполнения, скрипт выполняется. Передаю get параметры, все ок.
Не могу понять, как отправлять и получать post параметры. Помогите пожалуйста.
Код:
var
s: string;
begin
s := Path('php\php.exe ');
s := s + Path('index.php');
TextToWebBrowser(WebBrowser1, GetDosOutput(s));
end.
function Path(s: string): string;
begin
Result := PathAppend(ExtractFilePath(paramstr(0)), s);
end; //Path
function PathAppend(path, str: string): string;
begin
if path[Length(path)] <> '\' then path := path + '\';
result := path + str;
end; //PathAppend
procedure TextToWebBrowser(WB: TWebBrowser; Text: string);
var
V: OleVariant;
Document: IHTMLDocument2;
begin
if WB.Document = nil then WB.Navigate('about:blank');
while WB.Document = nil do Application.ProcessMessages;
Document := WB.Document as IHtmlDocument2;
V := VarArrayCreate([0, 0], varVariant);
V[0] := Text;
Document.Write(PSafeArray(TVarData(v).VArray));
Document.Close;
end; //TextToWebBrowser
function GetDosOutput(DosApp: String): string;
const
ReadBuffer = 2400;
var
Buffer: PChar;
BytesRead: DWord;
Apprunning: DWord;
start: TStartUpInfo;
ReadPipe, WritePipe: THandle;
Security: TSecurityAttributes;
ProcessInfo: TProcessInformation;
begin
result := '';
with Security do
begin
nlength := SizeOf(TSecurityAttributes);
binherithandle := true;
lpsecuritydescriptor := nil;
end;
if Createpipe(ReadPipe, WritePipe, @Security, 0) then
begin
Buffer := AllocMem(ReadBuffer + 1);
FillChar(Start,Sizeof(Start),#0);
start.cb := SizeOf(start);
start.hStdOutput := WritePipe;
start.hStdInput := ReadPipe;
start.dwFlags := STARTF_USESTDHANDLES +
STARTF_USESHOWWINDOW;
start.wShowWindow := SW_HIDE;
if CreateProcess(nil,
PChar(DosApp),
@Security,
@Security,
true,
NORMAL_PRIORITY_CLASS,
nil,
nil,
start,
ProcessInfo)
then
begin
repeat
Apprunning := WaitForSingleObject(ProcessInfo.hProcess, 100);
Application.ProcessMessages;
until (Apprunning <> WAIT_TIMEOUT);
repeat
BytesRead := 0;
ReadFile(ReadPipe, Buffer[0], ReadBuffer, BytesRead, nil);
Buffer[BytesRead]:= #0;
//OemToAnsi(Buffer,Buffer);
result := result + String(Buffer);
until (BytesRead < ReadBuffer);
end;
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
CloseHandle(ReadPipe);
CloseHandle(WritePipe);
FreeMem(Buffer);
end;
end;