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. Registry access problem

Registry access problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasewindows-adminquestion
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
    Mogaambo
    wrote on last edited by
    #1

    this i used to access information from registry, but the problem is that it prints only first character of the string , instead of whole. void GetProxyServerInfo() { try { HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), 0L, KEY_ALL_ACCESS, &hKey)!=ERROR_SUCCESS) printf("nError opening the desired subkey (doesn't exist?).n"); else { DWORD dwType = REG_SZ; char buf[255] = {0}; DWORD dwBufSize = 255; if( RegQueryValueEx(hKey,TEXT("ProxyServer"),0, &dwType, (LPBYTE)&buf, &dwBufSize) == ERROR_SUCCESS) { //here it prints only single character, not the whole string cout<< buf; } else cout << "can not query for key value\n"; RegCloseKey(hKey); } } catch(char *error) { throw error; } }

    “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

    J 1 Reply Last reply
    0
    • M Mogaambo

      this i used to access information from registry, but the problem is that it prints only first character of the string , instead of whole. void GetProxyServerInfo() { try { HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), 0L, KEY_ALL_ACCESS, &hKey)!=ERROR_SUCCESS) printf("nError opening the desired subkey (doesn't exist?).n"); else { DWORD dwType = REG_SZ; char buf[255] = {0}; DWORD dwBufSize = 255; if( RegQueryValueEx(hKey,TEXT("ProxyServer"),0, &dwType, (LPBYTE)&buf, &dwBufSize) == ERROR_SUCCESS) { //here it prints only single character, not the whole string cout<< buf; } else cout << "can not query for key value\n"; RegCloseKey(hKey); } } catch(char *error) { throw error; } }

      “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

      J Offline
      J Offline
      Jijo Raj
      wrote on last edited by
      #2

      Hello Mogaambo, Is unicode defined? then use wcout instead of cout. Regards, Jijo.

      _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

      M 1 Reply Last reply
      0
      • J Jijo Raj

        Hello Mogaambo, Is unicode defined? then use wcout instead of cout. Regards, Jijo.

        _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

        M Offline
        M Offline
        Mogaambo
        wrote on last edited by
        #3

        i used wcout still the problem exists.

        “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

        M 1 Reply Last reply
        0
        • M Mogaambo

          i used wcout still the problem exists.

          “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

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

          i used wchar_t this and problem solved.

          “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

          C 1 Reply Last reply
          0
          • M Mogaambo

            i used wchar_t this and problem solved.

            “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            It would be better to use TCHAR, so that you are independant of the unicode settings. Take a look at this article[^] for extended information.

            Cédric Moonen Software developer
            Charting control [v2.0 - Updated] OpenGL game tutorial in C++

            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