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. Adding a new registry VALUE

Adding a new registry VALUE

Scheduled Pinned Locked Moved C / C++ / MFC
helpwindows-admintutorial
4 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.
  • A Offline
    A Offline
    albean
    wrote on last edited by
    #1

    Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.

    B A A 3 Replies Last reply
    0
    • A albean

      Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.

      B Offline
      B Offline
      Brian Delahunty
      wrote on last edited by
      #2

      Have a look at: http://www.codeproject.com/system/cregisterex_svl.asp http://www.codeproject.com/system/cregistrykey.asp


      "Isn't that the "write once, debug everywhere" language?" Tom Archer on Java... :)

      1 Reply Last reply
      0
      • A albean

        Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.

        A Offline
        A Offline
        albean
        wrote on last edited by
        #3

        RegSetValueEx(hkey,"Test",0,REG_SZ, NULL,NULL) Did the trick. Thanks.

        1 Reply Last reply
        0
        • A albean

          Hi, I'm trying to add a new string value under an existing registry key. I see the APIs to delete , enum and set a value but I just can't figure out how to add a NEW string value under an EXISTing key. Please help. Thanks! This is what i've tied but it creates a KEY and not a VALUE under "Info" if(RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info", 0, KEY_ALL_ACCESS, &hkey )==ERROR_SUCCESS) { if(RegSetValue(hkey,"Info",REG_SZ,"Test",5)==ERROR_SUCCESS) I'd like to see Test appear as a REG_SZ under the Info Key.

          A Offline
          A Offline
          Aizik Yair
          wrote on last edited by
          #4

          Hi, This will solve your problem. unsigned long ValueSize = 10; // you can use also sizeof ( long ) or anything you need. if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BFW\\SampleTool\\Info , 0, KEY_READ|KEY_SET_VALUE, &hKey) != ERROR_SUCCESS ) { // error message. return; } RegSetValueEx(hKey,"Info",NULL,REG_SZ,(unsigned char*)5,ValueSize); Aizik Yair Software Engineer

          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