调用.FindByType会使VB6错误出来,对吗? [重复]

问题描述 投票:0回答:1

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

[基本上,我只是使用uPNPDeviceFinder类.FindByType方法,.FindByUDN来搜索uPnP设备,但是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中,我得到了上面的错误,有人有什么想法吗?谢谢。
c# .net vb.net visual-studio vb6
1个回答
1
投票
该函数在typelib中声明为

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此类型库,使用后果自负。用mktyplib编译的IDL。

请注意,您不必将vbupnp.tlb交付给用户,也不必在他们的计算机上注册。只需在您的开发机器上注册并使用它即可。

© www.soinside.com 2019 - 2024. All rights reserved.