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 label设置为背景透明

Delphi firedac 连接sql server一些要注意的地方

Delphi 关闭进程方法

Delphi-获取毫秒-计算代码运行的时间

Delphi 如何编写使stringgrid中的一列具有check功能,和checkbox效果一样

winapi 字符及字符串函数(7): ischarlower - 是否是个小写字母

Delphi firedac fdconnection 事务

Delphi android device information

Delphi 调用api打开文件 使用系统默认打开方式进行打开

Delphi编写dll(以及静态和动态方式调用)

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



打赏

取消

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

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

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

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

评论

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