PersonalCorpus 版 (精华区)
发信人: sql (灿烂的笑容), 信区: Database
标 题: 在PB中如何得到计算机的IP地址
发信站: 哈工大紫丁香 (2002年04月04日20:46:13 星期四), 站内信件
声明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.d
ll"
function string GetHost(string lpszhost, ref blob lpszaddress ) library "pbw
s32.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
--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.229.154]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:7.038毫秒