CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2006
    Posts
    40

    How to make registry key accessible to all users?

    Hi,
    this is my code:
    Code:
     
      LONG ret;
      HKEY keyHandle;
      String msg;
    
      ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE,  "Software\\myKey",
             0, KEY_ALL_ACCESS, &keyHandle);
    
      if (ret != ERROR_SUCCESS)
      {
        msg = "Open key failed.";
         ret = Application->MessageBoxA(msg.c_str(),"Error",MB_OK);
        if (ret == ID_OK)
        {};
        exit(0);
      }
    
      CHAR  value[80];
      value[0] = '\0';
      DWORD valueSize;
      char valueName[64];
      DWORD valueNameSize;
      DWORD n=0;
    
      for (n=0; n<2;n++) {
          valueSize=64;
          valueNameSize = 64;
          ret=RegEnumValue(keyHandle, n, valueName, &valueNameSize,NULL, NULL, value, &valueSize);
          if (ret == ERROR_NO_MORE_ITEMS) break;
          msg = (String)valueName + "=" +(String)value;
          Application->MessageBoxA(msg.c_str(),"Read Value",MB_OK);
      }
      ret=RegCloseKey(keyHandle);
    I have admi rights and i created myKey manually in my account. The code worked. I could get
    values from myKey.
    However, RegOpenKeyEx fails when someone who login without admi rights. What can I do
    to let myKey can be accessed by all the users no matter what privilege they have?
    Thanks for help

  2. #2
    Join Date
    Nov 2008
    Location
    india
    Posts
    53

    Re: How to make registry key accessible to all users?

    what is the error code.

  3. #3
    Join Date
    Nov 2008
    Location
    india
    Posts
    53

    Re: How to make registry key accessible to all users?

    use KEY_READ and try

  4. #4
    Join Date
    Jun 2006
    Posts
    40

    Re: How to make registry key accessible to all users?

    Thanks, lok.vikram,
    The error code is 5. KEY_READ worked for some computers but not all the cases. Any other suggestion?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured