PB下如何获取本机IP ( 积分: 50 )

  • 主题发起人 主题发起人 xxg6688
  • 开始时间 开始时间
X

xxg6688

Unregistered / Unconfirmed
GUEST, unregistred user!
// FUNCTION ulong gethostbyname ( String name) LIBRARY "wsock32.dll"
// FUNCTION Long gethostname ( REF String name, Long namelen) LIBRARY "wsock32.dll"
// FUNCTION uLong RtlMoveMemory(ref hostent hpvDest,long hpvSource,long cbCopy) Library "kernel32.dll"
// FUNCTION uLong RtlMoveMemory(ref Long hpvDest,long hpvSource,long cbCopy) Library "kernel32.dll"
// FUNCTION uLong RtlMoveMemory(ref ipaddress hpvDest,long hpvSource,long cbCopy) Library "kernel32.dll"


string ls_hostname = space(255),ls_ip=''
long ll_ip
//hostent lhst_host
long ll_dwIPAddr
int li_loop = 1
//ipaddress tmpipaddr

if gethostname(ls_hostname,255) = -1 then

messagebox('错误','获取主机名出错!')
return '-1'
end if

ls_hostname = trim(ls_hostname)
ll_ip = gethostbyname(ls_hostname)
if ll_ip = 0 then

messagebox('错误','获取ip地址出错!')
return '-1'
end if
RtlMoveMemory(lhst_host,ll_ip,16)
RtlMoveMemory(ll_dwIPAddr,lhst_host.haddrlist,4)
do
while ll_dwIPAddr <> 0
RtlMoveMemory(tmpipaddr,ll_dwIPAddr,4)
if li_loop = 1 then

ls_ip = ls_ip + string(asc(tmpipaddr.addr1)) +'.'+ string(asc(tmpipaddr.addr2)) +'.'+ string(asc(tmpipaddr.addr3)) +'.'+ string(asc(tmpipaddr.addr4))
else

ls_ip = ls_ip + ',' + string(asc(tmpipaddr.addr1)) +'.'+ string(asc(tmpipaddr.addr2)) +'.'+ string(asc(tmpipaddr.addr3)) +'.'+ string(asc(tmpipaddr.addr4))
end if
RtlMoveMemory(ll_dwIPAddr,lhst_host.haddrlist+li_loop*4,4)
li_loop ++
loop
return ls_ip

以上为从网上的PB代码, 请问哪位有pbws32.dll文件, 请发我Email: xxg6688@163.com
 
后退
顶部