使用 UPnP InvokeAction 获取 IP 地址不返回任何内容,帮助? [英] Getting IP Address using UPnP InvokeAction not returning anything, help?

查看:32
本文介绍了使用 UPnP InvokeAction 获取 IP 地址不返回任何内容,帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,当我使用 vb.net 或 c#.net 来执行此操作时,它可以完美运行,但是当我使用 vb6 时,它不起作用,在我的 for 循环中,相关设备中的相关服务被捕获,这是不返回结果的代码...

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 相关的东西都有效,即:检索设备列表并获取每个设备中的服务等...没有问题,只是 InvokeAction 似乎没有在我试图使用它的服务上工作on(在 "WANConnectionDevice:1" 类型的设备中属于 "WANIPConnection: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 中,最后一个参数是返回值),甚至无法让它工作,如果需要,可以提供关于我如何做到这一点的代码,但我很高兴直接运行它而不寻找返回值,因为这只是由这个列表定义的这里:http://msdn.microsoft.com/en-us/library/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 注意到该操作实际上正在运行/执行,但 out 参数数组(或 VB 中的 ByRef 参数)未使用数据更新,这表明 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.

推荐答案

这很简单.这些参数是包含一个元素的数组的变体,索引 = 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.

这篇关于使用 UPnP InvokeAction 获取 IP 地址不返回任何内容,帮助?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆