DOS执行工具即时返回结果

易语言 2020-07-19 18:28:19

DOS执行工具即时返回结果

.如果 (编辑框2.内容 ≠ “”)
SECURITY_ATTRIBUTES.nLength = 12
SECURITY_ATTRIBUTES.lpSecurityDescriptor = 0
SECURITY_ATTRIBUTES.bInheritHandle = 1
tmp = CreatePipe (hRead, hWrite, SECURITY_ATTRIBUTES, 0)
STARTUPINFO.cb = 68
GetStartupInfo (STARTUPINFO)
STARTUPINFO.dwFlags = 位或 (#STARTF_USESHOWWINDOW, #STARTF_USESTDHANDLES)
STARTUPINFO.wShowWindow = #SW_HIDE
STARTUPINFO.hStdOutput = hWrite
STARTUPINFO.hStdError = hWrite
CreateProcess (0, 编辑框2.内容, 0, 0, 真, 0, 0, 0, STARTUPINFO, PROCESS_INFORMATION) ' 测试命令 ping 127.0.0.1
tmp = CloseHandle (hWrite)
.循环判断首 ()
txt = 取空白字节集 (4096)
tmp = ReadFile (hRead, txt, 4095, len, 0)
编辑框1.内容 = 编辑框1.内容 + 取字节集数据 (txt, #文本型)
处理事件 ()
.循环判断尾 (tmp ≠ 0)
编辑框2.内容 = “”
.否则
信息框 (“没有输入任何信息!”, 0, “错误”)