Sorry I meant HKCU.
The second part of your question I don't understand fully but here goes
Case 1: Suppose you want to store personalization information for a user
(and there is not a enough of it to merit a file).
You app would check HKCU\Software\yourapp\somekey if it does not exist it
will create the key. Since the HKCU hive is different for each user only the
customization of the user running the app will be read from the registry.
You can do this within the application code because every user can write to
their HKCU
Case 2: Suppose you want to store some personal information but also write
information common to all users
If you want to write to machine wide state for an application the better
thing to do is have a configuration file (say config.xml) and put the path
to the file as part of setup in HKLM. Since you can specify that application
installation requires administrative privileges you can do it as part of the
installer. Secondly as part of the installer you would set permissions on
config.xml so all app users can write to it.
The alternative (create a registry key under HKLM and allow all users to
write to it) is possible but it is far easier and scalable (especially with
XML) to use files for this purpose. If you do want to create a key with
special permissions then the one call you could use (Win32 unfortunately) is
RegSetKeySecurity
Case 3: You have a requirement where you have to dynamically write to HKCR
or HKLM
I can't think of scenarios where you cannot work around this. If you have
one tell me and I'll let you know if there is a work around. In the worst
case you are down to using the win32 call above in your installer.
Hope I am not answering a completely different question.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subjected to the terms specified at
http://www.microsoft.com/info/cpyright.htm.