Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Windows7, regsvr32 doesn't write to HKCR\CLSID

I have created a new simple COM object in Visual Studio 2008 using the ATL-wizard. The object has a single class and simple methods. The ATL-wizard did generate .rgs-files for my class.

When I run regsvr32 Simple.dll on my XP machine the class is registered, information shows up in HKCR\Simple.SimpleObject and in HKCR\CLSID\{guid} as I expect.

However, on my 64bit Windows 7 machine it's not the same. I run regsvr32 as administrator the parts in HKCR\Simple.SimpleObject show up. But the part in HKCR\CLSID never gets there. And hence I cannot create new instances. (Being desperate I have tried both regsvr32 in System32 and in SysWOW64, same effect.)

Why dont regsrv32 put data into HKCR\CLSID?

like image 945
leiflundgren Avatar asked Dec 16 '22 16:12

leiflundgren


2 Answers

HKCR is an alias for HKLM\Software\Classes but it doesn't show everything. Look in HKLM\Software\Wow6432Node\Classes\CLSID for the registered {guid}. Which is where c:\system32\syswow64\regsvr32.exe writes them.

You did mention that you already tried that. There's something really wrong with that, you cannot arbitrarily run either version of Regsvr32.exe and get the same DLL registered. A 32-bit DLL cannot be loaded in a 64-bit process. In other words, there's no way for the 64-bit version of Regsvr32.exe to register a 32-bit COM server. And the other way around. Why you didn't get an error message is unguessable from here, the only sane explanation is that you somehow didn't actually run the right version of Regsvr32.

To really debug this, use SysInternals' ProcMon utility. Its trace shows you how the ATL registrar is writing the keys in the registry.

like image 97
Hans Passant Avatar answered Mar 13 '23 02:03

Hans Passant


32bit applications and components are getting redirected to a different part of the registry. If you are browsing the registry with the 64bit version of regedit you will not find it at the location you expect.

Therefore your component should register itself in HKEY_CLASSES_ROOT\Wow6432Node\CLSID.

In this registry path it should be visible to all 32bit applications.

See also:

  • Windows 64-bit registry v.s. 32-bit registry
  • David Broman's CLR Profiling API Blog: WOW64 and Your Profiler
like image 35
Robert Avatar answered Mar 13 '23 01:03

Robert