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

前端 未结 3 1020
太阳男子
太阳男子 2020-12-07 02:14

What does this error mean in VB6?

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

3条回答
  •  一整个雨季
    2020-12-07 03:06

    This is the declaration for FindByType() as retrieved from the type library:

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

    Note the 2nd argument, unsigned long. VB6 doesn't support unsigned types. It is not a problem in VB.NET or C#, they do support them.

    This problem is fixable if you have the Windows SDK installed. You should have it if you have a recent version of Visual Studio. Use the Visual Studio Command Prompt, then:

    • run oleview.exe c:\windows\system32\upnp.dll
    • type Ctrl+A, Ctrl+C to copy the type library content
    • run notepad.exe, Ctrl+V. Search for "unsigned" and delete it. There are two.
    • save the file to a temporary directory with the name upnp.idl
    • run midl upnp.idl /tlb upnp.tlb
    • copy the generated upnp.tlb to your project directory

    You can now add upnp.tlb instead of upnp.dll, you should no longer get the error. -

提交回复
热议问题