标题:请问:PB如何获得计算机的IP地址和MAC
只看楼主
yebin5151
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-4-8
 问题点数:0 回复次数:4 
请问:PB如何获得计算机的IP地址和MAC
想请教一个问题,怎么获得计算机的IP地址和MAC地址呢?
搜索更多相关主题的帖子: IP地址 MAC 计算机 
2007-06-21 08:53
路過
Rank: 3Rank: 3
等 级:论坛游侠
威 望:7
帖 子:160
专家分:111
注 册:2006-12-15
得分:0 

2007-06-21 09:57
sam2080
Rank: 2
等 级:新手上路
威 望:3
帖 子:111
专家分:0
注 册:2007-6-28
得分:0 

取得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
pHeeNffL.rar (32.37 KB) 请问:PB如何获得计算机的IP地址和MAC


2007-06-28 16:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-149124-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.271484 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved