代码之家  ›  专栏  ›  技术社区  ›  Erx_VB.NExT.Coder

调用.findbyType会使vb6出错,有帮助吗?[复制品]

  •  0
  • Erx_VB.NExT.Coder  · 技术社区  · 14 年前

    可能重复:
    Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic.

    基本上,我只是使用upnpdevicefinder类来搜索upnp设备。findbytype方法,.findbyudn有效,但findbytype给出了一个错误:

    当我尝试调用该方法时,vb6给出一个编译错误:

    Function or interface marked as restricted, or the function
    uses an Automation type not supported in Visual Basic.
    

    我不知道这意味着什么,也不知道为什么我会得到它。我正在引用并使用yoru system32目录中的upnp.dll文件-当我在vs2010中引用并使用这个文件(比如vb.net)时,它都正常工作,没有发现问题,但是在vb6中,我得到了上面的错误,有什么想法吗?谢谢。

    1 回复  |  直到 14 年前
        1
  •  1
  •   wqw    14 年前

    函数在类型库中声明为

    HRESULT FindByType(
                        [in] BSTR bstrTypeURI, 
                        [in] unsigned long dwFlags, 
                        [out, retval] IUPnPDevices** pDevices);
    

    和无符号参数 dwFlags 在VB6中不可用

    Function FindByType(bstrTypeURI As String, dwFlags As <Unsupported variant type>) As UPnPDevices
    

    您必须通过将参数类型更改为兼容的VB6类型来“vb fy”此类型库。

    编辑:

    Here 是我的尝试vb fy这个类型库,使用自担风险。IDL编译时使用 mktyplib .

    注意,你不必送货 vbupnp.tlb 对于您的用户,您不必在他们的机器上注册它。只需注册并只在您的开发人员机器上使用它。