我编写了一个随意更改客户端iP的程序(客户端不是电脑,是仪器,有专门命令的),但是一旦远端IP更改,本地机子就无法辨认仪器,我想干脆把本地IP也改了算了,(另外问一下,如果客户端意外断开,如何辨认呢,indy控件好像用disconnect没有反应),望高手赐教,解决给分

解决方案 »

  1.   

    用点API就可以了,自己查查Delphi SDK帮助吧!
      

  2.   

    呵呵,这个实在太好办!!
    procedure TFrmMain.btnSetIPClick(Sender: TObject);
    begin
      winexec(pchar('netsh interface ip set address "本地连接" static ' + edtIP.Text + ' ' + edtMask.Text),sw_hide);
    end;
      

  3.   

    看看以下网络命令,自己去搞定吧!想怎么改就怎么改,改得你口吐白沫都可以!!:D
    C:\Documents and Settings\Administrator>netsh 
           netsh> 
           netsh>int ip 
           interface ip>dump 
           # ---------------------------------- 
           # 接口 IP 配置 
           # ---------------------------------- 
           pushd interface ip 
           # ″本地连接″ 的接口IP 配置(注:以下显示视具体机器情况而定) 
           set address name = ″本地连接″ source = static addr = 192.168.0.5 mask = 255.255.255.0 
           set address name = ″本地连接″ gateway = 192.168.0.2 gwmetric = 1 
           set dns name = ″本地连接″ source = static addr = 61.237.17.181 
           add dns name = ″本地连接″ addr = 211.97.168.129 
           add dns name = ″本地连接″ addr = 211.98.4.1 
           set wins name = ″本地连接″ source = static addr = none 
           # ″本地连接 2″ 的接口 IP 配置 
           set address name = ″本地连接 2″ source = dhcp 
           set dns name = ″本地连接 2″ source = dhcp 
           set wins name = ″本地连接 2″ source = dhcp 
           popd 
           # 接口 IP 配置结束