如何检查端口在Inno Setup中是否可用? [英] How to check if port is usable in Inno Setup?

查看:166
本文介绍了如何检查端口在Inno Setup中是否可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查某些端口是否可用?在Inno Setup中该怎么做? 有什么方法可以在Inno Setup中使用套接字?有图书馆吗?如果有的话如何导入和使用它?

I need to check some port is usable or not? How can do that in Inno Setup? Is there any way to use socket in to Inno Setup? Is there any library for this? If there how can import it and use it?

谢谢您的回答.

推荐答案

您可以使用我的函数检查端口是否可用:

You can use my function to check, if a port is available:

function CheckPortOccupied(Port:String):Boolean;
var
  ResultCode: Integer;
begin
  Exec(ExpandConstant('{cmd}'), '/C netstat -na | findstr'+' /C:":'+Port+' "', '', 0,
       ewWaitUntilTerminated, ResultCode);
  if ResultCode <> 1 then 
  begin
    Log('this port('+Port+') is occupied');
    Result := True; 
  end
    else
  begin
    Result := False;
  end;
end;

这篇关于如何检查端口在Inno Setup中是否可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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