本文介绍了VB.NET-以编程方式检查我的PC是否在路由器后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我可以使用哪些方法检查我的PC是否在路由器后面.我用谷歌搜索,发现不合适的答案.
当我检查内部IP时是否已足够完成,因为我认为直接连线而不位于路由器后面的PC不会具有诸如内部IP之类的东西.我说的对吗?
这样的简单声明在我的问题上是否可靠:

I want to know with which methods i would be able to check if my PC is behind a Router. I googled and found not the appropriate answer.
Is it enough done when i check for Internal IP, since i believe that PCs directly wired without being behind a Router dont have such like Internal IPs. Am i right?
Would a simple Statement like this be reliable on my question:

If MyIP.Contain("192.168") Then "This PC is behind a Router"

推荐答案


' This is VBScripting
Set theNatter = CreateObject( "HNetCfg.NATUPnP")
Dim mappingPorts
Set mappingPorts = theNatter.StaticPortMappingCollection
mappingPorts.Add 1024, "TCP", 1024, "192.168.1.170", TRUE, "App"



这是VBScripting,如果您的路由器具有UPnP之类的选项(大多数都有),则将端口转发到UPnP表.
您应该记住的一件事是,UPnP选项不是那么可靠.至少即使启用了它并且信息存储在我的路由器上,它也无法在我的PC上运行,但是是的,某些东西阻止了UPnP,并确保它不是默认的Windows防火墙,因为我已经完全访问了我的TCP App,所以依靠它,但是您可以尝试.

为什么使用VBScript而不是VB.NET,答案是,在我满怀希望创建更高级的UPnP函数的那一点上,失败的VStudio 2010失败了.
NET Framework 2、3、3.5具有一些缺陷,无法从com库"UPnPLib"中检测"UPnPNatClass",或者直接引用"system32"下的"hnetcfg.dll",这是不一样的.在目标NET 4上构建它的案例.
我的目标目前是NET 2,这就是为什么我放弃并使用经典的"VBScript"来实现的原因.



This is VBScripting and forwards a port to the UPnP Table, if your Router has such an Option like UPnP (most do have).
One thing you should memorize, the UPnP option is not that reliable. At least it doesnt work on my PC even it is enabled and the infos are stored on my Router, but yeah something is blocking the UPnP and im sure its not the default Windows Firewall, because i gave full access to my TCP App, so not rely on this but you can try it.

Why VBScript and not VB.NET, the answer is that the f***ing VStudio 2010 failed on the point where i had all my hopes to create a more advanced UPnP Function.
NET Framework 2, 3 , 3.5 has some flaws to detect the ''UPnPNatClass'' from the com library ''UPnPLib'' or by referencing directly to ''hnetcfg.dll'' under ''system32'' which is not the same case building it on Target NET 4.
My Target is currently NET 2 and thats why i gave up and do it with the classic one ''VBScript''.


这篇关于VB.NET-以编程方式检查我的PC是否在路由器后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 10:10