none
What would cause application to fail writing to the HKCU hive of Registry RRS feed

  • Question

  • We have an Outlook add-in, which for Outlook2003 is written in VS2005, .NET2.  We write the Registry entries in HKCU that are used by Outlook to start the add-in from our main application ... but on a few (VERY few!) machines, this writing to HKCU is failing, without throwing an exception.  In all cases of which we are aware, this is occurring on WinXP (x86) SP3.

    I'm scratching my head, pulling hair out trying to figure out WHY the Registry entries are NOT getting written; this works beautifully on almost all other machines, it just fails on a very few.


    mdpowers
    Tuesday, July 5, 2011 10:08 PM

Answers

All replies

  • I take it you have looked at the user's permission level to that particular registry key? I have seen on occassion where for some unknown reason a particular user does not have permission to certain keys in their own HKCU hive.

    Since including the following in our add-ins and checking its result, I have not seen the problem or gotten a call, but maybe the user's IT department is now handling it when the error message appears. Or maybe we've just been lucky.

       Function AccessPrivilegeOK() As Boolean
    
        Dim f4 As New RegistryPermission(PermissionState.Unrestricted, ThisAddIn.zAPPsPref)
        Try
          f4.Demand()
          Return True 'the user has full file access privileges
        Catch ex As Exception
          MsgBox(prvErr & vbcr & ex.Message, MsgBoxStyle.Critical, ThisAddIn.GCL)
          Return False
        End Try
    
      End Function
    
    


    Kind Regards, Rich ... http://greatcirclelearning.com
    Wednesday, July 6, 2011 3:18 AM
  • I went and checked the permissions on that, and even explicitly reset the permissions to "Full Control" for the HKCU and all child keys, to no avail.  I then logged in as another user, on a domain Admin account, and still nothing is getting written. 

    It's the only machine in our test facility that is showing this behavior, but we have had a couple of users get this as well, so it is important to figure this out.


    mdpowers
    Wednesday, July 6, 2011 3:52 PM
  • Hi mdpowers,

    Thanks for posting in the MSDN Forum.

    Can you modify this registry hive manually?

    It’s based on my experience that try to modify the registry hive to see whether the user has right to modify it.

    I will show my step which I want to use for trouble shooting:

    1.       Try to run regedit.exe to see whether the account has right to modify the registry hive.

    2.       Try to find out whether the keys: HKEY_CURRENT_USER\SoftWare\Microsoft\Office\Outlook\Addins\[you add-in name].Connect, HKEY_CLASSES_ROOT\[you add-in name].Connect and HKEY_CLASSES_ROOT\CLSID\{***}(This Clsid you will find in HKEY_CLASSES_ROOT\[you add-in name].Connect )exist.

    3.       If above all are correct, we need further research for you add-in.

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 7, 2011 6:13 AM
    Moderator
  • I am able to add subkeys to HKEY_CURRENT_USER\SoftWare\Microsoft\Office\Outlook\Addins manually using Regedit.exe.  I'll try exporting the appropriate key on a machine where it is getting written, and try to import that.  Not a fix, but maybe a workaround!
    mdpowers
    Friday, July 8, 2011 10:44 PM
  • OK, importing the keys from .reg files works.  For whatever reason, just the write of the keys from the C# program is failing.
    mdpowers
    Friday, July 8, 2011 11:15 PM
  • Hi mdpowers,

    I think you need show some snippet to me for check. Please take a look at this thread I provide some handle process for PowerPoint’s registry hive. http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/a9988181-2822-4436-a02b-240265f3562b and I suggest backup your registry before you try it.

    How to back up the registry

    Before you edit the registry, you’d better export the keys in the registry that you plan to edit, or back up the whole registry.

    If a problem occurs, you can then follow the steps in the How to restore the registry section of this article to restore the registry to its previous state.

    If you have any questions, please feel free to let me know.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 12, 2011 9:37 AM
    Moderator