Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

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

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.

I keep getting it when i call a particular method of a dll that comes with windows xp and beyond (in system32 called upnp.dll)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:windowssystem32upnp.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. -


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...