In Vista SP1 the function OaEnablePerUserTLibRegistration was added as a workaround for problems registering type librarys - see (from http://support.microsoft.com/kb/935200)
Here we are dealing with the case of mapping the HKEY_CLASSES_ROOT registry subtree to the HKEY_CURRENT_USER registry subtree and then registering a type library.
My question is: What is the scope of the OaEnablePerUserTLibRegistration call ie. at what point after making the call would an application need to make the call again if performing multiple activities on the registry?
I ask as I have observed the following behaviour when running as a non admin user:
An old application uses ATL::CComModule - it uses registry diversion to register itself at run time for the current user.
1. Under vista in a non admin setup calling ATL::CComModule::RegisterServer(TRUE) fails.
2. Calling OaEnablePerUserTLibRegistration then performing (1) also fails.
3. Calling OaEnablePerUserTLibRegistration then calling: ATL::CComModule::RegisterTypeLibrary() ATL::CComModule::RegisterServer(FALSE) succeeds.
The TRUE in (2) indicates that the RegisterServer call should include a RegisterTypeLibrary() call but under a non admin user the workaround OaEnablePerUserTLibRegistration does not fix the problem.
Explicitly calling OaEnablePerUserTLibRegistration then RegisterTypeLibrary and finally RegisterServer(FALSE) does appear to work.
What I would like is some confirmation that my observations are true and some documentation that explains how long the effect of calling OaEnablePerUserTLibRegistration lasts so that I can be sure of my application's behaviour.
I cannot confirm or repro your behavior so I will answer only the question regarding the scope of OaEnablePerUserTLibRegistration. The API's effect will last till oleaut32.dll (from which it is exported) is loaded. So if your scenario is
1) Call OaEnablePerUserTLibRegistration (which may or may not result in loading of oleaut32.dll ).
2) unload oleaut32.dll
3) Call RegisterTypeLib (directly or via ATL)
In the above scenario, calling RegisterTypeLib will reload oleaut32.dll and you wont get the desired registry redirection effect. However, if you do not do step 2 then you would certainly get the desired registry redirection.