DOS par Pipe

Résolu
Filipe35 Messages postés 470 Date d'inscription vendredi 14 novembre 2003 Statut Membre Dernière intervention 23 octobre 2007 - 19 janv. 2005 à 14:38
Filipe35 Messages postés 470 Date d'inscription vendredi 14 novembre 2003 Statut Membre Dernière intervention 23 octobre 2007 - 21 janv. 2005 à 18:45
bonjour:

comment faire du DOS par Pipe ?

Filipe

2 réponses

Filipe35 Messages postés 470 Date d'inscription vendredi 14 novembre 2003 Statut Membre Dernière intervention 23 octobre 2007 1
21 janv. 2005 à 18:45
Salut,

c'est un source que j'avais trouvé pour VB.
son nom c'était Dos par pipe.
en gros elle permettait de lancer une aplication dos
et de l'afficher dans un mémo...(en cours de fonctionnement)
mais la j'ai juste besoin de récupéré le résultat.

J'ai trouvé la solution pour Delphi (elle ne vient pas de moi):
Elle était devant mes yeux, cf ma source RAR PASS Cracker pour lancer Unrar.exe

procedure RunDosInMemo(DosApp:String;Aedit:TEdit) ;
const
ReadBuffer = 2400;
var
Security : TSecurityAttributes;
ReadPipe,WritePipe : THandle;
start : TStartUpInfo;
ProcessInfo : TProcessInformation;
Buffer : Pchar;
BytesRead : DWord;
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(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) ;
AEdit.Text := AEdit.text + String(Buffer) ;
until (BytesRead < ReadBuffer) ;
end;
FreeMem(Buffer) ;
CloseHandle(ProcessInfo.hProcess) ;
CloseHandle(ProcessInfo.hThread) ;
CloseHandle(ReadPipe) ;
CloseHandle(WritePipe) ;
end;
end;

Désolé pour le dérangement.

Filipe

ps: merci comme meme de t'être pencher sur le sujet.
3
jmp77 Messages postés 1119 Date d'inscription lundi 4 février 2002 Statut Membre Dernière intervention 4 octobre 2006 7
20 janv. 2005 à 16:55
Hello,



Peux tu préciser ce que tu entends par là? Pipe???

Bonne prog,
JMP77.

N'oubliez pas de cliquer sur réponse acceptée.
0
Rejoignez-nous