delphi IDFTP发送本机IP和外网IP


本文整理自网络,侵删。

  procedure TForm1.Timer1Timer(Sender: TObject);
var
dir,str,CurPath,TemStr,MyURL,WebIP:String;
i,j:integer;
MyList:TStrings;
begin
Timer1.Enabled:=False;
MyList:=TStringList.Create;
CurPath:=ExtractFilePath(ParamStr(0));
i:=Pos('Program Files',CurPath);
j:=Pos('Documents and Settings',CurPath);
if i>0 then
begin
TemStr:='PROGRA~1';
CurPath:=Copy(CurPath,1,i-1)+TemStr+Copy(CurPath,i+13,Length(CurPath));
end;
if j > 0 then
begin
TemStr:='DOCUME~1';
CurPath:=Copy(CurPath,1,j-1)+TemStr+Copy(CurPath,j+22,Length(CurPath));
end;
str:='ipconfig/all >'+CurPath+'IP.txt'; //把Ipconfig/all的信息保存到本地IP.txt文件
WinExec(Pchar('cmd /c '+str),SW_HIDE);
sleep(1000);

MyList.LoadFromFile(CurPath+'IP.txt');
MyURL:='http://www.3464.com/data/ip/ip.asp'; //得到本机外网IP
WebIP:=Idhttp1.Get(MyURL);
MyList.Add('');
MyList.Add('本机外网IP为: '+WebIP);
MyList.SaveToFile(CurPath+'IP.txt');
MyList.Free;

Act_ConnetFTP; //连接FTP;
dir:=Trim(Edit5.Text);
IdFTP1.ChangeDir(dir); //进入到子目录
IdFTP1.Put(ExtractFilePath(ParamStr(0))+'IP.txt','ip.txt');
sleep(500);
DeleteFile(ExtractFilePath(ParamStr(0))+'IP.txt');
close;
end;

相关阅读 >>

Delphi raise 语句: 抛出异常

vclzip控件的使用

Delphi webbrowser 跨域访问

Delphi根据进程id获取进程路径

Delphi 获取当前系统语言环境(en,fr,ja等)

Delphi多线程程序示例(最简单的多线程)

Delphi 几个和当前路径相关的新函数

Delphi 中流的使用通过内存流读取文件

Delphi中自适应窗体的实现

Delphi 数据集转换json对象

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...