机器有多网卡,所以有多个ip地址,怎么得到所有的ip地址列表?
解决方案 »
- 轻松50分:求一段字符串处理的程序,寻找字符串中所有的email地址并自动替换为其他email地址
- 我想知道这个Sender是什么,怎么传递进来的,有什么办法吗,谢谢啊
- 请问DELPHI内如何批量修改SpeedButton的Groupindex
- 如何用Delphi写个能在IE中嵌入的窗口?
- 如何把缓冲区内的8字节十六进制数据转化成十进制数据
- 怎样在程序中进行控制,使某个特定的控件显示在最上层?
- IDTCPClient文件的程序文件传输!在线等!
- ORACLE 存储过程问题
- 郁闷死了
- 高分送:怎样将超过打印机宽度的位图,缩小其尺寸,并且打印出来!
- 怎样发送和接受基于tcp/ip协议的数据包
- 如何直接用一个桌面数据库(Access),而不用通过ODBC
然后写程序读出ip列表。
反正一块网卡是这样的。多块就没试过。应该读注册表行的。
WSAStartup
gethostname
gethostbyaddr
......他会把结果写入Memo1里面的
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char szHostName[128];
AnsiString sWideBandIP;
WSADATA wsaData;
AnsiString addr; if(WSAStartup(0x202,&wsaData)!=0)
{
WSACleanup();
return;
}
if( gethostname(szHostName, 128) != 0 )
{
ShowMessage(WSAGetLastError());
return;
} // Get host adresses
HOSTENT * pHost;
int i; pHost = gethostbyname(szHostName); for( i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ )
{
AnsiString str="";
int j; for( j = 0; j < pHost->h_length; j++ )
{
addr="";
if( j > 0 )
str += ".";
str += IntToStr(((unsigned char*)pHost->h_addr_list[i])[j]);
}
// Display all IPs
Memo1->Lines->Add(str);
}
WSACleanup();
}
//
http://www.overbyte.be
http://www.rtfm.be/fpiette/indexuk.htm
http://users.swing.be/francois.piette/indexuk.htm
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;begin
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^[I] <> nil do begin
result:=StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;
http://overbyte.delphicenter.com/eng/download.html?url=http://overbyte.delphicenter.com/arch/icsbeta.zip