Manually generate ActiveX wrapper after TLBIMP-ed dlls?

前端 未结 1 609
夕颜
夕颜 2021-01-03 10:55

I have several ActiveX components that needed to be accessed from a C# project.

I can import them via Visual Studio\'s add reference dialog, which will also automati

1条回答
  •  一整个雨季
    2021-01-03 11:27

    Oh... found it after looking at the folder where TLBIMP belongs.

    It's called AxImp.

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AxImp.exe

    So basically, to generate a PIA DLL in your own customized namespace:

    1. Register your OCX

      regsvr32 abc.ocx

    2. Generate a strong name key pair for you ocx by running

      sn -k

    3. Run TLBIMP and specify the desired namespace

      tlbimp abc.ocx /primary /keyfile:abc.snk /out:abc.dll /namespace:MyNamespace

    4. Run AXIMP on the ocx and use the rcw switch to use your own manully generated PIA DLL.

      aximp abc.ocx /source /rcw:abc.dll

    That should do it.

    There are however some problems with ancient TLBs being imported. I am not sure how to fix that yet.

    0 讨论(0)
提交回复
热议问题