放出GUI程序读取控制台程序输出的源码,有人要吗?

cuihl 2003-01-12 08:54:24
留下mail.
...全文
35 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
copy_paste 2003-02-25
  • 打赏
  • 举报
回复
昨天看到DFW有, 以前在一个网上也见到有,没几行代码就贴之。。。
copy_paste 2003-02-25
  • 打赏
  • 举报
回复
得到DOS运行命令的输出

procedure Tform1.formCreate(Sender: TObject);
begin
Memo1.Clear;
Edit1.Text := 'ipconfig'
end;

procedure Tform1.Button1Click(Sender: TObject);
const
ReadBuffer = 65535;
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(Edit1.Text),@Security,@Security,true,NORMAL_PRIORITY_CLASS,
nil,nil,start,ProcessInfo) then
begin
repeat
Apprunning := WaitForSingleObject(ProcessInfo.hProcess,250);
Application.ProcessMessages;
until (Apprunning <> WAIT_TIMEOUT);
Repeat
BytesRead := 0;
ReadFile(ReadPipe,Buffer[0],ReadBuffer,BytesRead,nil);
Buffer[BytesRead]:= #0;
OemToAnsi(Buffer,Buffer);
Memo1.Text := Memo1.text + String(Buffer);
until (BytesRead < ReadBuffer);
end;
FreeMem(Buffer);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
CloseHandle(ReadPipe);
CloseHandle(WritePipe);
end;
end;
chendaiyin 2003-02-25
  • 打赏
  • 举报
回复
急!!!
andersenchan@msn.com
谢谢楼主!
banxian 2003-02-24
  • 打赏
  • 举报
回复
azsd@better365.com
我是用ASM的惨,有的控制台没有任何输出的,用WaitProgress可以等到但取不到输出,惨
anxiong 2003-01-22
  • 打赏
  • 举报
回复
an_xiong@163.com
交个朋友,如何
letmegoon 2003-01-22
  • 打赏
  • 举报
回复
letmegoon@sina.com
多谢!
haoqingqlm 2003-01-14
  • 打赏
  • 举报
回复
haoqingqlm@163.com
谢谢!
d983074 2003-01-14
  • 打赏
  • 举报
回复
d983074@163.com
谢谢!
IceTiger 2003-01-13
  • 打赏
  • 举报
回复
leon_sam@163.com


谢谢!
zwjchina 2003-01-13
  • 打赏
  • 举报
回复
zwjchinazwj@sina.com

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧