关于是用dotnet获取本机IP地址+计算机名的方法

时间:2023-03-08 17:29:37
关于是用dotnet获取本机IP地址+计算机名的方法

印象中在maxscript帮助文档里找到过方法,但是当时没记下来.只能通过dotnet实现了.

如果电脑有无线网卡和本地连接,可能会出现乱码,也问了写dotnet的朋友,提供了一些思路,不过最终还是使用了这个笨办法.

fn getIP_PCname =
(
cc = (dotnetclass "System.Net.Dns")
oo = cc.GetHostAddresses(cc.GetHostName())
for ip = to oo.count do
(
getip = filterString (oo[ip].tostring()) "."
if getip.count > and (finditem getip "") != do
return (IP_pcname = oo[ip].tostring() + "@" + cc.GetHostName()) -- = sysinfo.computername
)
)--获取本机IP地址与计算机名

把获得的所有地址循环一遍,使用含有"192"第地址...目前只能这样解决,找到更好办法再补充.