获得使用UPnP invokeAction没有返回任何IP地址,求助?地址、UPnP、invokeAction、IP

2023-09-03 08:10:16 作者:掐死你的温柔

基本上,当我使用vb.net或C#.NET要做到这一点,它完美的作品,但是当我使用VB6,这是行不通的,在我的for循环,其中相关的服务在相关的设备被捕获,这里是code返回任何结果......

Basically, when i use vb.net or c#.net to do this, it works perfectly, but when i use vb6, it doesn't work, in my for loop where the relevant service in the relevant device is captured, here is the code that returns no result...

      ' serv is properly declared and instantiated by the for loop.
      Dim xins(0)
      Dim xouts(0)

      MsgBox ("Starting..." & serv.ServiceTypeIdentifier & vbCrLf & serv.id & vbCrLf & serv.LastTransportStatus) ' all this shows correctly.

      serv.InvokeAction "GetExternalIPAddress", xins, xouts

      MsgBox (xouts(0)) ' this should print the ExternalIP, but prints an empty string.

基本上,xouts(0)应包含的IP地址,但它并没有(为相反,没有错误或异常引发空字符串)。

Basically, xouts(0) should contain the IP address, but it doesn't (is an empty string instead, no error or exception is raised).

所有其他upnp.dll相关的东西的工作,即:在检索设备列表,并在每个设备等获取服务...没有probs,只是invokeAction没有似乎没有工作的服务,我想使用它(这是类型WANIPConnection:1类型的设备WANConnectionDevice:1)..

all the other upnp.dll related stuff works, ie: retreiving devices list and getting the services in each device etc... no probs, just InvokeAction doesn't seem to be working on the service i am trying to use it on (which is of type "WANIPConnection:1" in the device of type "WANConnectionDevice:1")...

下面是接口的详细信息,以供参考: HTTP:/ /msdn.microsoft.com/en-us/library/aa382237(VS.85).aspx

here is the interface details for reference: http://msdn.microsoft.com/en-us/library/aa382237(VS.85).aspx

我试图得到InvokeAction(它显示为在我刚才提供的链接接口声明的最后一个参数的返回值,那主要是针对C / C ++的用户,在.NET和VB6,最后一个参数是返回值),甚至不能得到那个工作,可以提供code对我是怎么做的,如果需要的话,但我很高兴,只是运行它直出头也不回的返回值,因为这只是定义通过这个列表在这里: http://msdn.microsoft .COM / EN-US /库/ aa381160(V = VS.85)的.aspx 和实际数据我在找的应该是在xouts阵列,特别是xouts(0),没有任何人有任何导致什么这可能是?

i tried to get the return value from InvokeAction (which is shown as the last argument in the interface declaration at the link i just provided, thats mainly for C/C++ users, in .NET and VB6, the last argument is the return value) and even couldn't get that to work, can provide code on how i did that if needed, but i'm happy to just run it straight out without looking for the return value, as that is just defined by this list here: http://msdn.microsoft.com/en-us/library/aa381160(v=VS.85).aspx and the actual data i'm looking for is supposed to be in xouts array, specifically xouts(0), does anyone have any leads on what this could be?

防火墙问题可能?我在高架模式和UPnP运行设备(路由器)已启动。

firewall issue maybe? i'm running in elevated mode and upnp is enabled on device (router).

更新:VIE注意到行动实际上是正在运行/执行,但输出参数数组(或ByRef参数在VB中)未更新的数据,这表明有关互操作性问题,是一个不错的领先优势markj评论

Update: vie noticed that the action is actually being run/executed but the out argument array (or ByRef argument in VB) is not being updated with the data, which suggests markj comments about interop issues being a good lead.

推荐答案

这是pretty的简单。这些参数,目的是要包含具有一个元素的数组变体,索引= 0

This is pretty straightforward. Those parameters are meant to be Variants that contain an array with one element, index = 0.

Dim xins As Variant, xouts As Variant
:
:
ReDim xins(0), xouts(0)
serv.InvokeAction "GetExternalIPAddress", xins, xouts
MsgBox xouts(0)

我一直在使用了一段时间,没有任何问题已经。

I've been using this for some time with no problems.