Things I learnt this week: RegSvr32.EXE on Windows x64

roger's picture

On Windows, 64-bit processes cannot load 32-bit DLLs, and 32-bit processes cannot load 64-bit DLLs. How does REGSVR32.EXE manage to successfully register both 32-bit and 64-bit COM DLLs?

On Windows x64 (I've checked on Windows Vista and Windows 2003, and I assume it's the same for Windows XP and Windows 2008) there are two copies of REGSVR32.EXE. One of them is in C:\Windows\System32, and is 64-bit; the other is in C:\Windows\SysWOW64, and is 32-bit.

If you attempt to use the 64-bit version of REGSVR32.EXE to register a 32-bit DLL, it spots this and spawns the 32-bit version to do the registration. Similarly, if you attempt to use the 32-bit version of REGSVR32.EXE to register a 64-bit DLL, it spawns the 64-bit version.

Comments

Thanks for sharing your

Thanks for sharing your insight! I now understand why I sometimes see one instance of regsvr32.exe in Task Manager / Processes, and sometimes see two. The default Image Name window happened to be just narrow enough that I didn't see the *32 at the end of one of the names until I widened the window. I still don't know why one of my dll's is causing regsvr32 to hang, but one mystery is solved.

Careful when registering .net dlls!

If you attempt to use the 64 version of REGSVR32.EXE on a .net dll, the dll will be jit compiled and ran as a 64 bit process, and similarly if you use 32 bit version of REGSVR32 you get a 32 bit process. The exception to this is of course, if your dll targets a specific platform. So if your .net dll relies on an unmanaged dll, your .Net dll either needs to target the same platform as your unmanaged dll or you need to ensure you launch the correct version of REGSVR32.EXE.

Information about registering managed COM objects

There are two versions of Regasm. One for 32 bit and one for 64 bit registration. See Creating and Using Managed Elevated COM

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.