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 shall i create a key in registry

how shall i create a key in registry

Scheduled Pinned Locked Moved C / C++ / MFC
c++windows-adminhelp
5 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.
  • N Offline
    N Offline
    NewtonOfComputers
    wrote on last edited by
    #1

    hello all, how shall i create a entry in registry using VC++. i mean i need to add a key such that my application name shouldnt appear there. i mean there is an entry named "Extensions" in the registry and i need to create an entry {"Demo App"} in that. and then i need to add entries in the newly created. but the problem with SetRegistryKey() is that it is creating the application name too. but i dont need it. how shall i do so. ComputerNewton

    2 N 2 Replies Last reply
    0
    • N NewtonOfComputers

      hello all, how shall i create a entry in registry using VC++. i mean i need to add a key such that my application name shouldnt appear there. i mean there is an entry named "Extensions" in the registry and i need to create an entry {"Demo App"} in that. and then i need to add entries in the newly created. but the problem with SetRegistryKey() is that it is creating the application name too. but i dont need it. how shall i do so. ComputerNewton

      2 Offline
      2 Offline
      224917
      wrote on last edited by
      #2

      int RegWriteKeyValue(HKEY hKeyParent,CString strPath,CString strKey,CString strVal) { CRegKey regKey; DWORD dwKeyCreateMode=REG_OPENED_EXISTING_KEY; long lRes; lRes=regKey.Create(hKeyParent,strPath,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&dwKeyCreateMode); if (lRes != ERROR_SUCCESS) return 0; lRes=regKey.SetValue(strVal,strKey); if (lRes != ERROR_SUCCESS) return 0; // close the registry key regKey.Close(); return 1; } RegWriteKeyValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce","Name","value");


      It's not a bug, it's an undocumented feature.
      suhredayan@omniquad.com

      messenger :suhredayan@hotmail.com

      N 1 Reply Last reply
      0
      • 2 224917

        int RegWriteKeyValue(HKEY hKeyParent,CString strPath,CString strKey,CString strVal) { CRegKey regKey; DWORD dwKeyCreateMode=REG_OPENED_EXISTING_KEY; long lRes; lRes=regKey.Create(hKeyParent,strPath,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&dwKeyCreateMode); if (lRes != ERROR_SUCCESS) return 0; lRes=regKey.SetValue(strVal,strKey); if (lRes != ERROR_SUCCESS) return 0; // close the registry key regKey.Close(); return 1; } RegWriteKeyValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce","Name","value");


        It's not a bug, it's an undocumented feature.
        suhredayan@omniquad.com

        messenger :suhredayan@hotmail.com

        N Offline
        N Offline
        NewtonOfComputers
        wrote on last edited by
        #3

        Thank u very much for ur help. But it is in ATL. i dont want to use this in ATL. once again thanks a lot. b'coz of ur reply i got an idea and i did it in SDK mixed with MFC to get my requirement. Once again thank u very much. ComputerNewton

        P 1 Reply Last reply
        0
        • N NewtonOfComputers

          Thank u very much for ur help. But it is in ATL. i dont want to use this in ATL. once again thanks a lot. b'coz of ur reply i got an idea and i did it in SDK mixed with MFC to get my requirement. Once again thank u very much. ComputerNewton

          P Offline
          P Offline
          Prakash Nadar
          wrote on last edited by
          #4

          use CRegKey of ATL classes.


          God is Real, unless declared Integer.

          1 Reply Last reply
          0
          • N NewtonOfComputers

            hello all, how shall i create a entry in registry using VC++. i mean i need to add a key such that my application name shouldnt appear there. i mean there is an entry named "Extensions" in the registry and i need to create an entry {"Demo App"} in that. and then i need to add entries in the newly created. but the problem with SetRegistryKey() is that it is creating the application name too. but i dont need it. how shall i do so. ComputerNewton

            N Offline
            N Offline
            Navin
            wrote on last edited by
            #5

            Use the Win32 registry functions. Ugly, yes, but they work:// First create the key. HKEY hNewKey = NULL; DWORD disposition = 0; DWORD error = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Extensions\\Demo App", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey, &disposition); // Now create the value char myString[] = "Some Data"; error = ::RegSetValueEx(hNewKey, "Some Value", NULL, REG_SZ, myString, sizeof(myString));
            See MSDN on RegCreateKeyEx and RegSetValueEx for more info. (The code I provided is just a rough example... should compile and work but I can't be sure!) Sometimes I feel like I'm a USB printer in a parallel universe.

            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