Using 32-bit or 64-bit ActiveX Components on x64 Windows

64-bit Windows is capable of running applications in both 32-bit mode and 64-bit mode.
If the application process is running in a 32-bit address space, the DLL must also use a 32-bit address space. (In other words, it should be a DLL compiled for the Win32 platform.) If the application process is running in a 64-bit address space, the DLL’s address space must match — i.e. it should be a DLL compiled for the x64 platform. Just because your application is running on 64-bit Windows does not mean it requires a 64-bit DLL — the determining factor is the process’s address space.

For example, let’s say you’ve configured IIS to run its worker processes in 32-bit mode. In that case, your ASP apps would require 32-bit DLLs. If IIS is running in 64-bit mode, then 64-bit DLLs are needed.

About the Windows registry and ActiveX:

A 64-bit Windows system has two separate registries — one for 32-bit processes, and one for 64-bit processes. The reason for this makes sense if you think about it.. Let’s say your application instantiates an instance of an ActiveX component by calling CreateObject(“Chilkat.Ssh”). If your application is running in a 32-bit address space, the registry entries for “Chilkat.Ssh” should point to a 32-bit DLL in the filesystem. However, if your application is running in a 64-bit address space, the registry entries should point to a 64-bit DLL. How can you do both with one registry? The answer is to have separate registries — one for 32-bit and one for 64-bit.

Therefore, when you register a DLL with regsvr32 — did you register the 32-bit DLL in the 32-bit registry, or did you register the 64-bit DLL in the 64-bit registry? You’ll need to get it right. When you run regsvr32 on an x64 system, you’re running the 64-bit version by default. (That’s a bit confusing because of the “32” in the regsvr32 name…) To run the 32-bit regsvr32, do this:

cd \windows\syswow64
regsvr32 c:\filename.dll

(Note the stupidity of it all — the default regsvr32 is 64-bit and resides in the \windows\system32 directory. Note the “32” in system32 and the “32” in regsvr32 — quite misleading. However the 32-bit version of regsvr32 is found in the \windows\syswow64 directory. Note the “64” in the directory name. That’s also misleading. Ughhh!)

More information about: regsvr32 or ActiveX object creation errors.

Tags :