Fórum [Ajuda] Capturar saída do msdos #190129
22/10/2003
0
Companheiros, preciso da ajuda de vcs, usei a rotina abaixo para capturar a saída de comando do msdos, porem não está retornando absolutamente nada, estou usando o XP com SO, se alguem puder ajudar ou dar uma dica.
valew,
var
StartupInfo : TStartupInfo;
ProcessInformation : TProcessInformation;
Rc : Boolean;
Handle : THandle;
begin
GetStartUpInfo(StartUpInfo);
Handle := CreateFile(´c:\teste.txt´,GENERIC_READ or GENERIC_WRITE,0,nil,CREATE_ALWAYS,0,0);
with StartUpInfo do
begin
hstdOutPut := Handle;
wShowWindow := sw_show;
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
end;
rc := CreateProcess(nil,´cmd dir ´,nil,nil,True,0,nil,nil,StartUpInfo,ProcessInformation);
if rc then
WaitForSingleObject(ProcessInformation.hProcess,INFINITE);
CloseHandle(handle);
Memo1.Lines.LoadFromFile(´c:\teste.txt´);
DeleteFile(´c:\teste.txt´);
valew,
var
StartupInfo : TStartupInfo;
ProcessInformation : TProcessInformation;
Rc : Boolean;
Handle : THandle;
begin
GetStartUpInfo(StartUpInfo);
Handle := CreateFile(´c:\teste.txt´,GENERIC_READ or GENERIC_WRITE,0,nil,CREATE_ALWAYS,0,0);
with StartUpInfo do
begin
hstdOutPut := Handle;
wShowWindow := sw_show;
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
end;
rc := CreateProcess(nil,´cmd dir ´,nil,nil,True,0,nil,nil,StartUpInfo,ProcessInformation);
if rc then
WaitForSingleObject(ProcessInformation.hProcess,INFINITE);
CloseHandle(handle);
Memo1.Lines.LoadFromFile(´c:\teste.txt´);
DeleteFile(´c:\teste.txt´);
Samurai
Curtir tópico
+ 0
Responder
Posts
22/10/2003
Samurai
Errei ao postar o codigo acima, a linha esta como
rc := CreateProcess(nil,´cmd /c dir ´,nil,nil,True,0,nil,nil,StartUpInfo,ProcessInformation);
rc := CreateProcess(nil,´cmd /c dir ´,nil,nil,True,0,nil,nil,StartUpInfo,ProcessInformation);
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)