
24.10.2014, 23:16
|
 |
LMD-DML
|
|
Регистрация: 12.07.2009
Адрес: Богородское
Сообщения: 3,025
Версия Delphi: D7E
Репутация: 1834
|
|
Пример из drkb (02101)
Код:
procedure RDM(CmdLine:string; AMemo:TMemo);
const ReadBuffer = 2400;
var
Security: TSecurityAttributes;
ReadPipe, WritePipe: THandle;
Start: TStartUpInfo;
ProcessInfo: TProcessInformation;
Buffer: Pchar;
BytesRead, Apprunning: DWord;
begin
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(CmdLine), @Security, @Security, true, NORMAL_PRIORITY_CLASS, nil, nil, Start, ProcessInfo)
then
begin
repeat
Apprunning:= WaitForSingleObject(ProcessInfo.hProcess,100);
ReadFile(ReadPipe, Buffer[0], ReadBuffer, BytesRead, nil);
Buffer[BytesRead]:= #0;
OemToAnsi(Buffer, Buffer);
AMemo.Text:= AMemo.text + String(Buffer);
until
(Apprunning <> WAIT_TIMEOUT);
end;
FreeMem(Buffer);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
CloseHandle(ReadPipe);
CloseHandle(WritePipe);
end;
end;
вариант вызова
Код:
RDM('\\dom\php.cmd 2123', Memo1);
|