写两个函数就可以了,获得计算机名:
string ls_hostname
int i
i = registryget("HKEY_LOCAL_MACHINE\system\CurrentControlSet\Control\computername\computername"&
,"computername",ls_hostname)
return ls_hostname
获得ip地址:
string ls_ip_address
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
return 'error'
ELSE
GetHost(ls_hostname, lb_HostAddress)
if ai_mode = 1 then
ls_IpAddress = string(asc(string(blobmid(lb_HostAddress,1,2))),"###") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,2,2))),"###") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,3,2))),"###") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,4,2))),"###")
else
ls_IpAddress = string(asc(string(blobmid(lb_HostAddress,1,2))),"000") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,2,2))),"000") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,3,2))),"000") + "."
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,4,2))),"000")
end if
END IF
WSACleanup()
ELSE
return 'error'
END IF
ls_ip_address = ls_IpAddress
return ls_ip_address