views:

36

answers:

1

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

Basically, im just searchign for uPnP devices using the uPNPDeviceFinder classes .FindByType method, .FindByUDN works, but FindByType gives an error:

VB6 gives a compile error when I attempt to call the method:

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

i have no idea what this even means or why i am getting it. I am referencing and using the upnp.dll file as found in yoru system32 directory - when i reference and use this in VS2010 (say, vb.net) it all works and no issues are found, but in VB6, i get the error above, any ideas anyone? thanks.

+2  A: 

The function is declared in the typelib as

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

and the unsigned parameter dwFlags is unusable in VB6

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

You have to "VB-fy" this typelib by changing param types to compatible VB6 types.

Edit:

Here is my attempt to VB-fy this typelib, use at your own risk. IDL compiled with mktyplib.

Note that you don't have to ship vbupnp.tlb to your users, you don't have to register it on their machines. Just register and use it on your dev machine only.

wqw
Hi, how do I do this or what can I do on the vb end to get this to work since I can't edit the dll? Thanks
Erx_VB.NExT.Coder
Remove reference to `upnp.dll` and use `vbupnp.tlb` instead. If you prefixed class names with `UPNPLib` change that to `VBUPNPLib`.
wqw
thanks mate, you are a ledgend, i was trying to get it working but midl was spitting out c precompiler warnings and couldn't convert from idl to tlb, thank you. upvoted and accepted as answer.
Erx_VB.NExT.Coder
btw, do you recomment mktyplib over midl or?
Erx_VB.NExT.Coder
Both are usable, but `midl` tends to autogenerate stuff -- enum names, etc. -- so `mktyplib` is leaner and specificly targeted at typelibs and included in VB6 distro so its kind of "official" tool in VB6. `midl`'s main purpose is to generate interface proxies/stubs, typelibs kind of feel like byproduct.
wqw
thanks wqw, how do i learn about what proxies and stubs are and how to make use of these? i had never heard of .idl files and methods of tricking intellisense into using altered .tlb files.
Erx_VB.NExT.Coder