如何在Inno Setup中获取执行程序的输出? [英] How to get an output of an Exec'ed program in Inno Setup?

查看:467
本文介绍了如何在Inno Setup中获取执行程序的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获得Exec可执行文件的输出?

Is it possible to get an output of an Exec'ed executable?

我想向用户显示一个信息查询页面,但在输入框中显示MAC地址的默认值.还有其他方法可以实现这一目标吗?

I want to show the user an info query page, but show the default value of MAC address in the input box. Is there any other way to achieve this?

推荐答案

是的,使用将标准输出重定向到文件:

Yes, use redirection of the standard output to a file:

[Code]

function NextButtonClick(CurPage: Integer): Boolean;
var
  TmpFileName, ExecStdout: string;
  ResultCode: integer;
begin
  if CurPage = wpWelcome then begin
    TmpFileName := ExpandConstant('{tmp}') + '\ipconfig_results.txt';
    Exec('cmd.exe', '/C ipconfig /ALL > "' + TmpFileName + '"', '', SW_HIDE,
      ewWaitUntilTerminated, ResultCode);
    if LoadStringFromFile(TmpFileName, ExecStdout) then begin
      MsgBox(ExecStdout, mbInformation, MB_OK);
      { do something with contents of file... }
    end;
    DeleteFile(TmpFileName);
  end;
  Result := True;
end;

请注意,可能有多个网络适配器,因此有多个MAC地址可供​​选择.

Note that there may be more than one network adapter, and consequently several MAC addresses to choose from.

这篇关于如何在Inno Setup中获取执行程序的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆