How can we make an ActiveX control interact with a USB controller?

I am attempting to write an ActiveX control that will play an audio file while accepting commands from a USB-connected foot pedal.

The USB foot pedal dll is a unmanaged, non COM-compliant dll that requires p/invoke to be used from .NET.

How can I use an unmanaged DLL inside an ActiveX control

I need this to work with Vista and IE7.


Answer this question

How can we make an ActiveX control interact with a USB controller?

  • idos

    I am replying to my own post in case somebody else has a similar question.

    To use an unmanaged .dll in an .NET ActiveX control, you must pre-install the .dll to the C:\Windows\System32 directory. COM+ and .NET dependencies will be downloaded automatically.

    Your ActiveX control will need full trust, so you have two options:
    Give the containing zone permissions to run full trust (Control Panel>Administrative>.NET 2.0 Configuration)

    Strong name your assembly and all .net dependencies through Visual Studio. It is not difficult to generate a self-signed strong name using VS2005. Then, assign full trust to just your .dll.

    You will also need to place this in front of one of your classes:
    [SecurityPermission( SecurityAction.Demand, UnmanagedCode=true, SkipVerification=true)]

    This will demand unmanaged code permissions. If you do not demand permissions, they will not be given, and your unmanaged code will not run.

    Nathanael Jones

  • How can we make an ActiveX control interact with a USB controller?