?? 調(diào)用那個(gè)函數(shù)得到本機(jī)的ip (2000年8月15日).txt
字號(hào):
調(diào)用那個(gè)函數(shù)得到本機(jī)的IP (2000年8月15日)
本站更新 分類: 作者:zsm (嘎子) 推薦: 閱讀次數(shù):785
(http://www.codesky.net)
--------------------------------------------------------------------------------
struct hostent *thisHost;
struct in_addr in;
char MyName[80];
char *IP,*ptr;
if(gethostname (MyName,80)==SOCKET_ERROR)
return NULL;
if(!(thisHost = gethostbyname(MyName)))
return NULL;
memset((void *)&in,sizeof(in),0);
in.s_addr=*((unsigned long *)thisHost->h_addr_list[0]);
if(!(ptr = inet_ntoa(in)))
return NULL;
IP = new char[strlen(ptr)+1],
strcpy(IP,ptr);
return IP;
是在vc下編的,而這兩個(gè)函數(shù)是api函數(shù),delphi應(yīng)該也能用
--------------------------------------------------------------------------------
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -