jun353835273 发表于 2020-4-10 23:28:23

获取外网IP地址

(defun getuip( address / ob html)
        (setq ob (vlax-create-object "Msxml2.XMLHTTP"))
        (vlax-invoke-method ob "open" "get" address "false")
        (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke-method (list ob "send")))
                (princ "\nµ±Ç°ÎÞÍøÂçÁ¬½Ó")
                (setq html (vlax-get-property ob "responseText"))
        )
        (vlax-release-object ob)
        html
)
(getuip "http://icanhazip.com" )

ynhh 发表于 2020-7-4 12:45:50

请教大师,这可以有内网的吗?
外网可判断地区,不知如有内网的话能判断什么?

jun353835273 发表于 2020-7-4 15:58:52

ynhh 发表于 2020-7-4 12:45
请教大师,这可以有内网的吗?
外网可判断地区,不知如有内网的话能判断什么?

可以简单的判断内网的ip地址

或者参看晓东论坛有
http://bbs.xdcad.net/forum.php?mod=viewthread&tid=714967&highlight=ping
(XD::Internet:Ping "www.baidu.com")
(defun XD::Internet:Ping (address / out ws)
(and (setq ws (vlax-get-or-create-object "WScript.Shell"))
       (setq out (vlax-invoke
                   ws
                   'run
                   (strcat "ping.exe -n 1 " address)
                   0
                   :vlax-true
               )
       )
       (vlax-release-object ws)
       (zerop out)
)
)

松树石头哥 发表于 2020-11-19 15:59:25

页: [1]
查看完整版本: 获取外网IP地址