Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. RegOpenKeyEx Question

RegOpenKeyEx Question

Scheduled Pinned Locked Moved C / C++ / MFC
questionwindows-admin
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maneor
    wrote on last edited by
    #1

    Is there a way to test if a user has read or full access to certain registry entries? Will the return value of RegOpenKeyEx tell me this? Thanks!

    N F 2 Replies Last reply
    0
    • M maneor

      Is there a way to test if a user has read or full access to certain registry entries? Will the return value of RegOpenKeyEx tell me this? Thanks!

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      You can use RegGetKeySecurity.


      Nibu thomas Software Developer Faqs by Michael dunn

      M 1 Reply Last reply
      0
      • M maneor

        Is there a way to test if a user has read or full access to certain registry entries? Will the return value of RegOpenKeyEx tell me this? Thanks!

        F Offline
        F Offline
        Frank K
        wrote on last edited by
        #3

        Possible another way .. if(ERROR_SUCCESS != RegOpenKeyEx(...)) { //Get the error code DWORD LastError = GetLastError(); //Get the error code as text (example) TCHAR szBuf[80]; LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); sprintf(szBuf, "Error %d: %s", LastError, lpMsgBuf); MessageBox(NULL, szBuf, "Error", MB_OK); LocalFree(lpMsgBuf); } HTH Frank

        1 Reply Last reply
        0
        • N Nibu babu thomas

          You can use RegGetKeySecurity.


          Nibu thomas Software Developer Faqs by Michael dunn

          M Offline
          M Offline
          maneor
          wrote on last edited by
          #4

          Would you mind showing how to use this function? I'm using RegOpenKeyEX to get a handle to the key. Since RegGetKeySecurity requires a security descriptor, is there a way to get it from the handle? Thanks!

          N 1 Reply Last reply
          0
          • M maneor

            Would you mind showing how to use this function? I'm using RegOpenKeyEX to get a handle to the key. Since RegGetKeySecurity requires a security descriptor, is there a way to get it from the handle? Thanks!

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #5

            The RegGetKeySecurity function retrieves a copy of the security descriptor protecting the specified open registry key.

            LONG RegGetKeySecurity(
            HKEY hKey, // handle to key
            SECURITY_INFORMATION SecurityInformation, // request
            PSECURITY_DESCRIPTOR pSecurityDescriptor, // SD
            LPDWORD lpcbSecurityDescriptor // buffer size
            );

            Parameters
            hKey
            [in] Handle to an open key for which to retrieve the security descriptor.

            SecurityInformation
            [in] Specifies a SECURITY_INFORMATION value that indicates the requested security information.

            pSecurityDescriptor
            [out] Pointer to a buffer that receives a copy of the requested security descriptor.

            lpcbSecurityDescriptor
            [in, out] Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pSecurityDescriptor parameter. When the function returns, the variable contains the number of bytes written to the buffer.

            The above documentation clearly says how to do it. Did you look up the docs? Look at the statements marked in red.


            Nibu thomas Software Developer Faqs by Michael dunn

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups