编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛  
全能 ASP / PHP / ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
发新话题
打印

请问:PB如何获得计算机的IP地址和MAC

请问:PB如何获得计算机的IP地址和MAC

想请教一个问题,怎么获得计算机的IP地址和MAC地址呢?

TOP

TOP

取得IP地址的方法:

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

unsignedinteger version

unsignedinteger highversion

character discription[257]

character systemstatus[129]

unsignedinteger maxsockets

unsignedinteger maxupddg

string vendorinfo

二、在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"


三、使用方法:

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)

获取MAC地址请看附件中的DLL及PBL
附件: 只有本站会员才能下载或查看附件,请您 登录注册

TOP

发新话题