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. How do I read a particular registry key

How do I read a particular registry key

Scheduled Pinned Locked Moved C / C++ / MFC
windows-admintutorialquestion
8 Posts 4 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
    Matthew Devine
    wrote on last edited by
    #1

    Hi Everyone, I want to be able to read the Registry "ProxyEnable" located within HKEY_CURRENT_USER and located at the following path Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings. What I want to be able to do is tell whether "ProxyEnable" is on or off. Not quite sure how to do that particular piece though. Thanks in advance, Matt

    J RaviBeeR 2 Replies Last reply
    0
    • M Matthew Devine

      Hi Everyone, I want to be able to read the Registry "ProxyEnable" located within HKEY_CURRENT_USER and located at the following path Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings. What I want to be able to do is tell whether "ProxyEnable" is on or off. Not quite sure how to do that particular piece though. Thanks in advance, Matt

      J Offline
      J Offline
      Jose Lamas Rios
      wrote on last edited by
      #2

      Add KEY_QUERY_VALUE to the access rights specified when opening the key, and then use RegQueryValueEx[^]. -- jlr http://jlamas.blogspot.com/[^]

      M 1 Reply Last reply
      0
      • M Matthew Devine

        Hi Everyone, I want to be able to read the Registry "ProxyEnable" located within HKEY_CURRENT_USER and located at the following path Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings. What I want to be able to do is tell whether "ProxyEnable" is on or off. Not quite sure how to do that particular piece though. Thanks in advance, Matt

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        See Stuart Konen's excellent CRegistry[^] class. :cool: My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music | Trips ravib@ravib.com

        1 Reply Last reply
        0
        • J Jose Lamas Rios

          Add KEY_QUERY_VALUE to the access rights specified when opening the key, and then use RegQueryValueEx[^]. -- jlr http://jlamas.blogspot.com/[^]

          M Offline
          M Offline
          Matthew Devine
          wrote on last edited by
          #4

          The issue I seem to be having is that ProxyEnable is actually a Reg_DWORD key, so I don't think I'm reading it in correctly and I'm not sure how to verify that its actually an enabled key. Basically if I were to get a value back from doing a query on that key, what do I compare its value to?

          J 1 Reply Last reply
          0
          • M Matthew Devine

            The issue I seem to be having is that ProxyEnable is actually a Reg_DWORD key, so I don't think I'm reading it in correctly and I'm not sure how to verify that its actually an enabled key. Basically if I were to get a value back from doing a query on that key, what do I compare its value to?

            J Offline
            J Offline
            Jose Lamas Rios
            wrote on last edited by
            #5

            Matthew Devine wrote: Basically if I were to get a value back from doing a query on that key, what do I compare its value to? As I understand it, 1 means enabled, 0 means disabled... -- jlr http://jlamas.blogspot.com/[^]

            M 1 Reply Last reply
            0
            • J Jose Lamas Rios

              Matthew Devine wrote: Basically if I were to get a value back from doing a query on that key, what do I compare its value to? As I understand it, 1 means enabled, 0 means disabled... -- jlr http://jlamas.blogspot.com/[^]

              M Offline
              M Offline
              Matthew Devine
              wrote on last edited by
              #6

              Yeah that's exactly right, that's what I'm seeing HKEY hKeyRoot,hKeyNew; LPCTSTR lpSubKey; LPTSTR Value; DWORD retcode; DWORD Value_type; DWORD Value_data; DWORD Value_size; hKeyRoot = HKEY_CURRENT_USER; lpSubKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; Value = "ProxyEnable"; retcode = RegOpenKeyEx ( hKeyRoot, lpSubKey, 0, KEY_QUERY_VALUE, &hKeyNew ); if (retcode != ERROR_SUCCESS) MessageBox("Error opening key",_T("NO")); retcode = RegQueryValueEx ( hKeyNew, // HKEY (hkey) handle of key to query Value, // LPSTR (lpValueName) address of name of value to query NULL, // LPDWORD (lpReserved) reserved &Value_type, // LPDWORD (lpType) address of buffer for value type (BYTE *) &Value_data,// LPBYTE (lpData) address of data buffer &Value_size // LPDWORD (lpcbData) address of data buffer size ); if (retcode != ERROR_SUCCESS) MessageBox("Error reading key",_T("NO")); else fout<<"Registry Value - "<

              J D 2 Replies Last reply
              0
              • M Matthew Devine

                Yeah that's exactly right, that's what I'm seeing HKEY hKeyRoot,hKeyNew; LPCTSTR lpSubKey; LPTSTR Value; DWORD retcode; DWORD Value_type; DWORD Value_data; DWORD Value_size; hKeyRoot = HKEY_CURRENT_USER; lpSubKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; Value = "ProxyEnable"; retcode = RegOpenKeyEx ( hKeyRoot, lpSubKey, 0, KEY_QUERY_VALUE, &hKeyNew ); if (retcode != ERROR_SUCCESS) MessageBox("Error opening key",_T("NO")); retcode = RegQueryValueEx ( hKeyNew, // HKEY (hkey) handle of key to query Value, // LPSTR (lpValueName) address of name of value to query NULL, // LPDWORD (lpReserved) reserved &Value_type, // LPDWORD (lpType) address of buffer for value type (BYTE *) &Value_data,// LPBYTE (lpData) address of data buffer &Value_size // LPDWORD (lpcbData) address of data buffer size ); if (retcode != ERROR_SUCCESS) MessageBox("Error reading key",_T("NO")); else fout<<"Registry Value - "<

                J Offline
                J Offline
                Jose Lamas Rios
                wrote on last edited by
                #7

                Matthew Devine wrote: This seems to have solved the problem that I was having Good! Matthew Devine wrote: Thanks again Jose, you have been a big help. You're welcome. Glad to be of help. -- jlr http://jlamas.blogspot.com/[^]

                1 Reply Last reply
                0
                • M Matthew Devine

                  Yeah that's exactly right, that's what I'm seeing HKEY hKeyRoot,hKeyNew; LPCTSTR lpSubKey; LPTSTR Value; DWORD retcode; DWORD Value_type; DWORD Value_data; DWORD Value_size; hKeyRoot = HKEY_CURRENT_USER; lpSubKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; Value = "ProxyEnable"; retcode = RegOpenKeyEx ( hKeyRoot, lpSubKey, 0, KEY_QUERY_VALUE, &hKeyNew ); if (retcode != ERROR_SUCCESS) MessageBox("Error opening key",_T("NO")); retcode = RegQueryValueEx ( hKeyNew, // HKEY (hkey) handle of key to query Value, // LPSTR (lpValueName) address of name of value to query NULL, // LPDWORD (lpReserved) reserved &Value_type, // LPDWORD (lpType) address of buffer for value type (BYTE *) &Value_data,// LPBYTE (lpData) address of data buffer &Value_size // LPDWORD (lpcbData) address of data buffer size ); if (retcode != ERROR_SUCCESS) MessageBox("Error reading key",_T("NO")); else fout<<"Registry Value - "<

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Matthew Devine wrote: ...the reason the compare wasn't working was simply because I only had 1 "="'s after for Value_data All the more reason to put the constant on the left side of the operator!


                  "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                  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