我现在要编一个汇编语言的开发工具,遇到如下问题:
    1). 怎样在delphi中操作dos命令?
    2). 怎样取得dos是的提示信息, 如:执行masm.exe a.asm;后如何得到以下的返回信息?Microsoft (R) Macro Assembler Version 5.00 
Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.
  50434 + 449790 Bytes symbol space free      0 Warning Errors
      0 Severe  Errors请各位老兄多多指教!

解决方案 »

  1.   

    rlsource.zip创建标准输入输出
    var
      SecAttr: TSecurityAttributes;
    const
      PIPE_SIZE = 0; //--was: 1024;
    begin
      SecAttr.nLength := SizeOf(SecAttr);
      SecAttr.lpSecurityDescriptor := nil;
      SecAttr.bInheritHandle := true;  with FPipeInput do
      begin
        if not CreatePipe(hRead, hWrite, @SecAttr, PIPE_SIZE)
          then WinError('Error on STDIN pipe creation : ');
        if not DuplicateHandle(GetCurrentProcess, hRead, GetCurrentProcess,
          @hRead, 0, true, DUPLICATE_CLOSE_SOURCE or DUPLICATE_SAME_ACCESS)
          then WinError('Error on STDIN pipe duplication : ');
      end;
      with FPipeOutput do
      begin
        if not CreatePipe(hRead, hWrite, @SecAttr, PIPE_SIZE)
          then WinError('Error on STDOUT pipe creation : ');
        if not DuplicateHandle(GetCurrentProcess, hWrite, GetCurrentProcess,
          @hWrite, 0, true, DUPLICATE_CLOSE_SOURCE or DUPLICATE_SAME_ACCESS)
          then WinError('Error on STDOUT pipe duplication : ');
      end;
      with FPipeError do
      begin
        if not CreatePipe(hRead, hWrite, @SecAttr, PIPE_SIZE)
          then WinError('Error on STDERR pipe creation : ');
        if not DuplicateHandle(GetCurrentProcess, hWrite, GetCurrentProcess,
          @hWrite, 0, true, DUPLICATE_CLOSE_SOURCE or DUPLICATE_SAME_ACCESS)
          then WinError('Error on STDERR pipe duplication : ');
      end;
    end;设置标准输入输出
        StartupInfo.wShowWindow := FShowWindow;
        StartupInfo.hStdInput := FPipeInput.hRead;
        StartupInfo.hStdOutput := FPipeOutput.hWrite;
        StartupInfo.hStdError := FPipeError.hWrite;用建立进程
     CreateProcess(szExecutable, szCommandline, nil, nil, true,
          (CREATE_DEFAULT_ERROR_MODE and Integer(FDefaultErrorMode))
          or (CREATE_SUSPENDED and Integer(FStartSuspended) or liPriorityClass),
          Environment, szDirectory, StartupInfo, FProcessInfo)
    然后读程序输出结果
    if PeekNamedPipe(FRedirector.FPipeOutput.hRead, nil, 0, nil,
          @FRedirector.FAvailable, nil) and (FRedirector.FAvailable > 0) then
        begin
          Synchronize(FRedirector.ReadStdOutput);
          Idle := false;
        end;    //-- check for StdErr-Pipe
        if PeekNamedPipe(FRedirector.FPipeError.hRead, nil, 0, nil,
          @FRedirector.FAvailable, nil) and (FRedirector.FAvailable > 0) then
        begin
          Synchronize(FRedirector.ReadStdError);
          Idle := false;
        end;