我想得到本台机器的ip地址和网卡号(即:网络适配器的MAC地址)

wjbboo 2004-08-28 03:02:53
我想得到本台机器的ip地址和网卡号(即:网络适配器的MAC地址)。在8.0下能好使的,我是新手
最好是不用我再改!谢谢
...全文
391 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
qqwwee112233 2004-09-13
  • 打赏
  • 举报
回复
up
wjbboo 2004-09-11
  • 打赏
  • 举报
回复
up
zy_zj_2004 2004-09-04
  • 打赏
  • 举报
回复
声明win32 API函数:
function int WSAStartup( uint UIVersionRequested, ref s_WSAData lpWSAData ) library "wsock32.dll"
function int WSACleanup() library "wsock32.dll"
function int WSAGetLastError ( ) library "wsock32.dll"
function int gethostname ( ref string name, int namelen ) library "wsock32.dll"
function string GetHost(string lpszhost, ref blob lpszaddress ) library "pbws32.dll"

使用方法:
s_wsadata l_WSAData
string ls_HostName = space(128)
string ls_IpAddress
int li_version = 257
blob{4} lb_hostaddress

IF wsastartup ( li_version, l_WSAData ) = 0 THEN

IF gethostname ( ls_HostName, len(ls_HostName) ) < 0 THEN
messagebox("GetHostName",WSAGetLastError())
ELSE
GetHost(ls_HostName, lb_HostAddress)
ls_IpAddress = string(asc(string(blobmid(lb_HostAddress,1,1))),"000") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,2,1))),"000") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,3,1))),"000") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,4,1))),"000")
END IF
WSACleanup()
ELSE
messagebox("GetHostName",WSAGetLastError())
END IF
sle_1.text=ls_hostname
sle_2.text=ls_ipaddress



wjbboo 2004-09-04
  • 打赏
  • 举报
回复
我的信箱是wjbboo@tom.com 谁给我发个8.0下好使的,谢谢!!~~
yanghongfeng 2004-08-31
  • 打赏
  • 举报
回复
找个winsock.pbl吧,网上多的是,那里可以得到你想要的东西,我有个例子。
兔子-顾问 2004-08-31
  • 打赏
  • 举报
回复
调api,忘了是哪个。买本书看看。
wjbboo 2004-08-31
  • 打赏
  • 举报
回复
也没有utils.dll它啊
我的信箱是wjbboo@tom.com谁有给我发个现成过来,我再加20分谢谢
要ip地址和mac
wjbboo 2004-08-31
  • 打赏
  • 举报
回复
想得到mac中找不到GetLanaID(lana)
这个函数??
还有没有得到ip地址的函数啊!!
wjbboo 2004-08-31
  • 打赏
  • 举报
回复
GetLanaID(lana)
找不到这个函数啊??????
TGWall 2004-08-31
  • 打赏
  • 举报
回复
取得IP地址的方法:

1、定义一个名为s_wsadata的结构,如下:

unsignedinteger version

unsignedinteger highversion

character discription[257]

character systemstatus[129]

unsignedinteger maxsockets

unsignedinteger maxupddg

string vendorinfo

2、在Local External Funtions中作如下的声明:

function int WSAStartup( uint UIVersionRequested, ref s_WSAData lpWSAData ) library "wsock32.dll"

function int WSACleanup() library "wsock32.dll"

function int WSAGetLastError ( ) library "wsock32.dll"

function int gethostname ( ref string name, int namelen ) library "wsock32.dll"

function string GetHost(string lpszhost, ref blob lpszaddress ) library "pbws32.dll"


3、使用方法:

s_wsadata l_WSAData

string ls_HostName = space(128)

string ls_IpAddress

int li_version = 257

blob{4} lb_hostaddress


IF wsastartup ( li_version, l_WSAData ) = 0 THEN

IF gethostname ( ls_HostName, len(ls_HostName) ) < 0 THEN

messagebox("GetHostName",WSAGetLastError())

ELSE


GetHost(ls_HostName, lb_HostAddress)

ls_IpAddress = string(asc(string(blobmid(lb_HostAddress,1,1))),"000") + "."

ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,2,1))),"000") + "."

ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,3,1))),"000") + "."

ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,4,1))),"000")


END IF


WSACleanup()

ELSE

messagebox("GetHostName",WSAGetLastError())

END IF


messagebox('ls_hostname: '+ls_hostname,'ls_ipaddress: '+ls_ipaddress)
sywen 2004-08-28
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3148/3148919.xml?temp=.5750543
http://community.csdn.net/Expert/topic/3112/3112503.xml?temp=.7899591
http://community.csdn.net/Expert/topic/3094/3094607.xml?temp=.9593317
好好研究吧!

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧