Delphi,如何获取所有本地IP? [英] Delphi, How to get all local IPs?
本文介绍了Delphi,如何获取所有本地IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看过另一个相关的问题了,在delphi中有一个方法可以得到一个简单的列表(例如tstrings)并且看起来似乎让我的头脑转化为delphi。
解决方案
在indy 9中,有一个单元IdStack, TIdStack类
fStack:= TIdStack.CreateStack;
try
edit.caption:= fStack.LocalAddress; //第一个地址我相信
ComboBox1.Items.Assign(fStack.LocalAddresses); //所有地址'
finally
freeandnil(fStack);
结束
工作很棒:)
Lebeau的评论
在Indy 10中也存在这一点,但
代码有点不同:
TIdStack.IncUsage;
try
GStack.AddLocalAddressesToList(ComboBox1.Items);
Edit.Caption:= ComboBox1.Items [0];
finally
TIdStack.DecUsage;
结束
Any one know a way in delphi get a simple list (eg tstrings) of the local ip address.
I have had a look at the other related question, and cant seem to get my head around converting them to delphi.
解决方案
in indy 9, there is a unit IdStack, with the class TIdStack
fStack := TIdStack.CreateStack;
try
edit.caption := fStack.LocalAddress; //the first address i believe
ComboBox1.Items.Assign(fStack.LocalAddresses); //all the address'
finally
freeandnil(fStack);
end;
works great :)
from Remy Lebeau's Comment
The same exists in Indy 10, but the code is a little different:
TIdStack.IncUsage;
try
GStack.AddLocalAddressesToList(ComboBox1.Items);
Edit.Caption := ComboBox1.Items[0];
finally
TIdStack.DecUsage;
end;
这篇关于Delphi,如何获取所有本地IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文