问题
I need to put some activeX in my .Net WinForm. The provider had sent me a .tlb and the com .dll.
Is this enough? How do I put it on winform?
回答1:
That should be sufficent. You'll need to register that dll on your machine, add it to the dev studio Toolbox (Right click on the toolbox/Choose Items) and go to the COM tab, if you can't find it in there you can browse to the specific location and select the Type Library to use.
After that you can just drag the new control to your form. A Reference to the library will be added to your project automatically.
see "Adding ActiveX Controls to Windows Forms"
回答2:
I have a similar problem (similar to the one described in this comment activex in winform ) with Visual Studio 2010 and an MFC application (instead of a Winform).
I have the my.ocx file and I registered it correctly with regsvr32 but I get the "Self-registration for my.ocx failed".
This link http://www.codeproject.com/Questions/262206/ActiveX-Problem-Unspecified-Error gives me some relevant info. I quote it:
Hi I have done some research regarding registering ActiveX control library in this area and I found that If am developing ActiveX control for 64 bit Operating Syatem and 64bit Aplication Then in this case we have to register this activeX control for both 64bit and 32bit operating system 64bit ActiveX control in System32 folder for 64bit operating system 32bit ActiveX control in SysWOW64 folder for 64bit operating system, For this we have to generate both version of ActiveX control in MFC x64 and Win32 both version Thankx
I looked in the registry at the key HKEY_CLASSES_ROOT\TypeLib\{myocx_typelib_id}\1.0\0\
and I found the two keys win64
and win32
. The win64
was pointing to the right ocx file while the win32
was pointing to the wrong ocx file (In my case the typelib is embedded in the ocx file). I correct the registry and solved the problem of "self-registration for my.ocx failed". In my case I have two different my.ocx files, the first is for win32 and the second is for win64.
来源:https://stackoverflow.com/questions/2194802/activex-in-winform