views:

412

answers:

2

I'm using Visual C++. I'd like to really only have the DLL registered for the current user, even if the users is an administrator.

For that reason, I changed all of the project.rgs references to HKCR. But, using Process Monitor while using regsvr32 to register the DLL, I notice that it still tries to create HKCR\TypeLib\{ ... }. This happens on the call to CComModule::RegisterServer().

Is this inherent of CComModule? Is there anything I'm missing, in terms of configuration of Visual C++? I know that I can use RegOverridePredefKey, but I don't want to load more DLLs, and it's not a very elegant solution.

+1  A: 

CComModule::RegisterServer() has a BOOL first parameter that indicates whether it should register the type library. Set it to FALSE and it will not try to.

sharptooth
The BOOL parameter in RegisterServer(..) is if to register the typelib, not to control the per user.
Shay Erlichmen
Yes, exactly. This parameter controls whether the code for registering the typeplib will be invoked. The OP's problem is that after his .rgs file is rolled into the registry the code for registering typlib is also invoked and rolls in the "HKCR\TypeLib\{Something} key.
sharptooth
Well, I don't want to *not* register it. I just want to make it register in `HKCU\Software\Classes\TypeLib`.
known
No problem - specify FALSE to RegisterServer() and insert the necessary statement to the .rgs file. I guess it'll be clearer if you set a breakpoint and then step into RegisterServer() - it calls UpdateRegistry() for the COM exposed classes and then registers a typelib in a standard way (in HKCR) if the first parameter is TRUE.
sharptooth
A: 

HKCR is not mapped to the current user registry hive, if you really want to register the server for the local user use HKEY_CURRENT_USER\Software\Classes instead of HKCR.

Shay Erlichmen