Mam oto taki ciekawy kod funkcja wywoluje cmd z parametrem zadanym w edit1 i w folderze c:\ tylko tyle wiem i prosze was jesli byscie mogli mi go nieco wytlumaczyc bo naprawde ciekawie wyglada lub dajcie jakiegos linka o podobnej tematyce [browar]
function ExecuteConsole(Executable:PChar; CommandLine:PChar; Directory:PChar):boolean;
const bufSize = 256;
var readPipe :THandle;
writePipe :THandle;
security :SECURITY_ATTRIBUTES;
info :STARTUPINFO;
process :PROCESS_INFORMATION;
buf :array[0..bufSize-1] of char;
bytesRead :DWord;
text :string;
line :string;
newLinePos :integer;
begin
result:=FALSE;
security.nLength:=sizeof(security);
security.lpSecurityDescriptor:=nil;
security.bInheritHandle:=TRUE;
Application.ProcessMessages;
if CreatePipe(readPipe, writePipe, @security, 0) then
begin
ZeroMemory(@info, sizeof(info));
with info do
begin
cb := sizeof( info );
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := 0;
hStdOutput := writePipe;
hStdError := writePipe;
end;
if CreateProcess(Executable, CommandLine, nil, nil, TRUE, 0, nil, Directory, info, process) then
begin
CloseHandle( writePipe );
text:='';
while ReadFile( readPipe, buf, bufSize, bytesRead, nil) do
begin
text:=text+buf;
repeat
newLinePos:=Pos(#13, text);
if (newLinePos=0) then break;
line:=copy(text,1, newLinePos-1);
delete(text, 1, newLinePos);
Form1.Memo1.Lines.Add(line);
Application.ProcessMessages;
until Application.Terminated;
ZeroMemory(@buf, bufSize);
end;
result:=TRUE;
end;
CloseHandle( readPipe );
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ExecuteConsole('c:\WINDOWS\system32\cmd.exe', PChar('/C "'+Edit1.Text+'"'), 'c:\');
Edit1.Text:='';
end;
</delphi>