In the previous blog posts we have described how to add an ActiveX component (control) to a Microsoft Visual Basic project and to a Microsoft Excel sheet. When you distribute your Visual Basic or Excel application you must remember to distribute the ActiveX component file (.OCX file) together with your other files. It is also important to install the ActiveX component in the correct folder in end-users’ computers’ hard disks, and it is also important to register the ActiveX component in the system.
The ActiveX component must be installed in the correct folder
It is important to install an ActiveX component to the correct folder in Windows. If the ActiveX component is not a side-by-side component (can run side-by-side with a component with same filename) the component must be installed to Windows system folder, or to another shared folder. You should also make a version check before you install the component to the folder. A version check ensures that a component with a lower version number never replaces a component with a higher version number.
If the ActiveX component is installed to a local folder (for example to the same folder as the application) and other versions of the component already exist in other folders, there may be a conflict if two different programs that uses different versions of the ActiveX component are running in the same time. The ActiveX component that is loaded first will prevent the second one be loaded to the memory, and if the second one is a newer version, there may be problem with missing properties, methods or events, which can lead to an unstable program or that the program doesn’t start all.
Most installers install ActiveX components to Windows system folder. That’s why you also should do the same. By installing the ActiveX component to the system folder, the problem described above will not happen. If you install a newer version of the ActiveX component, it will replace the older one. And there will always be only one version of the ActiveX component in the system. There will be no duplicates with different versions numbers.
Special considerations in a 64 bit Windows
Things are getting somewhat more complex in a 64 bit version of Windows operating system. In a 32 bit Windows there is only one system folder, but in a 64 bit Windows there are two system folders. One system folder is intended for 32 bit (executable) files and one system folder is intended for 64 bit (executable) files. It is important to copy the ActiveX component to the correct system folder, otherwise it will not be found by the application. The paths to the two system folders in a 64 bit Windows are the following:
For 64 bit files: C:\Windows\System32
For 32 bit files: C:\Windows\SysWOW64
We explain this further in the following technical article on our website:
> Windows 64-bit: The ‘Program Files (x86)’ and ‘SysWOW64’ folders explained
The ActiveX component must be registered in the system
Copying an ActiveX component to the correct folder in the end-user’s hard disk is just the half of the job. The ActiveX component must also be registered in the system before it can be used. If you use a setup program for the installation of your application and the ActiveX component, the setup program will probably register the ActiveX component for you. But if you distribute your application in another way, there is a special program in Windows that can be used to register the ActiveX component. The name of the program is Regsvr32 and it is quite simple to use the program. If you want to register an ActiveX component you should call the Regsvr32 program with a full file path to the ActiveX component as a command line parameter. For example:
Two versions of the Regsvr32 tool in a 64 bit Windows
If the Windows that you are running is 64 bit, you should be aware of that there is a 32 bit version and a 64 it version of the tool:
The file path to the 64-bit version is: C:\Windows\System32\regsvr32.exe
The file path to the 32-bit version is: C:\Windows\SysWOW64\regsvr32.exe
If your application and ActiveX component is 32 bit (which is very likely) you should use the Regsvr32 program that is located in the SysWOW64 folder.
You will find more detailed information about the Regsvr32 tool in the following article on Microsoft’s website:
> How to use the Regsvr32 tool and troubleshoot Regsvr32 error messages
It’s a good idea to use a setup tool
As you can see there are lots of things to consider when installing an ActiveX component in Windows. Doing all this manually will take some time. A better idea is to use a setup tool for this purpose. There exists many setup tools on the market today, but we have an easy to use setup tool that we recommend. You can read more here:
> SamLogic Visual Installer – An easy-to-use installation software