Rename a value in the registry?

This is a discussion on Rename a value in the registry? within the C++ Programming forums, part of the General Programming Boards category; Hello, I would like to know if any of you can tell me how I can edit a file in ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    13

    Angry Rename a value in the registry?

    Hello, I would like to know if any of you can tell me how I can edit a file in the registry using C/C++? I can go on my PC and run regedit and rename the file my self. But I am looking to make this step automated! I want to run my program and rename a file I have in the registry. The path I'm trying to reach is:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr
    entVersion\Policies\Ratings

    I'm looking to rename this file to:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr
    entVersion\Policies\Ratings1

    Thanks for any help...

    PS I looked up some of the reg functions. but becuase I don't know what I'm doing I don't want to run any of them till I hear from you.

    Thanks for your help
    Thanks,
    Cyberpuck52

    "If you know the enemy and know yourself, you need not fear the result of a hundred battles"
    -Sun Tzu, Art of War

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You can use RegSetValue() to set a registry value...

    The problem is that you seem to be trying to edit an actual subkey....I dont know if there's a function for this....

    You could delete the key and recreate it.......

    But why are you editing the key and not the contents? If you are working on the contents its easier

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    1) Don't cross post
    2) Don't post windows questions in any other forum other than the "Windows Programming" forum

    People will just get annoyed at you.

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    13
    Fordy -
    Would that change the name? Or is there a safe function that will delete the file? I'm just trying to delete the Ratings file! I don't want to hurt anything else. Would regdelex() get rid of this file, Ratings? what would you suggest to code if you just want to get rid of Ratings? I'm trying to avoid using regedit and doing it manually.

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
    CurrentVersion\Policies\Ratings

    Thanks

    Uraldor-
    Sorry if I annoyed you. I'm new. This is like my 5 post. I started in C and after doing more checking I found that this could have been in C++ or Windows. That is why you will find it there too. I feel like I'm at the first day of school again and everyone is ........ing on their locker to mark their territory! I will try to pay more attention and keep them in the right board.

    Thanks for your opinion,
    Thanks,
    Cyberpuck52

    "If you know the enemy and know yourself, you need not fear the result of a hundred battles"
    -Sun Tzu, Art of War

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    MSDN

    This will delete the key

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    it's not really a problem. you haven't annoyed me at all. i'm just letting you know so that you aren't going to get flamed by others in the future. If you have a question, post it to the right forum and the right forum only Trust me, it'll make you life alot easier.

    good luck!
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  7. #7
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    what are the parameters for the regsetvalue() function? the include is windows.h i am assuming, correct??

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Actually you should use RegSetValueEx().....

    Which is;
    Code:
    LONG RegSetValueEx(
      HKEY hKey,           // handle to key to set value for
      LPCTSTR lpValueName, // name of the value to set
      DWORD Reserved,      // reserved
      DWORD dwType,        // flag for value type
      CONST BYTE *lpData,  // address of value data
      DWORD cbData         // size of value data
    );
    (from MSDN)

  9. #9
    Unregistered
    Guest
    Thanks for all of your help everyone!!

    Is "Ratings" considered the "Value" here? I don't want to touch anything else just the "Ratings". And I want to keep it intact and just rename or just delete it.

    I'm looking to rename this file to:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr
    entVersion\Policies\Ratings


    I'm afraid if I use RegDeleteKey() would delete HKEY_LOCAL_MACHINE\... and I don't want to do that. I'm trying to set up a dummy PC so I can practice with these commands.

    I found this CeRegDeleteValue and RegDeleteValue on that same site Fordy. Have any of you ever used these commands? One of these sounds like what I'm looking for! I'm afraid to try them though...I don't want to hurt my PC.

    Can I use these commands in my dos program or do I have to make a windows program or a C++ program?

    It is sounding more and more that this is over my head and maybe I should read more on the registry.

    Fordy -
    >>Actually you should use RegSetValueEx().....

    Would this rename the "Ratings" value or create a new value?
    Ex-
    Before regSetValueEx()
    I have "Ratings"
    After RegSetValueEx()
    I have "Ratings1"
    else after RegSetValueEx()
    I have "Ratings" & "Ratings1"
    ????????????????????????????????


    Uraldor -
    Thanks for the advice. I will try to stick to it. Thanks again.


    Thanks everyone for your help. I know it is hard trying to teach someone who doesn't know anything about the registry how to delete/rename with out me messing it up. Thanks for your patience.

    Dan

  10. #10
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789

    I found this CeRegDeleteValue and RegDeleteValue on that same site Fordy. Have any of you ever used these commands? One of these sounds like what I'm looking for! I'm afraid to try them though...I don't want to hurt my PC.
    I havent done much direct programming with the registry, but it seems to me that you want to edit the name of a key not a value. Try to think of keys as directories and values as files. I dont know any functions to rename a key....but thinking..... I guess there must be one..... I'll look into it

    Can I use these commands in my dos program or do I have to make a windows program or a C++ program?
    If you are using a windows compiler that has the libraries to use these functions (Borland Builder, VC++, Devc++) you can use a full Win32 Application or a simple console program.
    Fordy -
    >>Actually you should use RegSetValueEx().....

    Would this rename the "Ratings" value or create a new value?
    Ex-
    Before regSetValueEx()
    I have "Ratings"
    After RegSetValueEx()
    I have "Ratings1"
    else after RegSetValueEx()
    I have "Ratings" & "Ratings1"
    ????????????????????????????????
    ratings is a subkey not a value. The key normally contains a "default" value or others, so RegSetValueEx() would edit them

  11. #11
    Registered User
    Join Date
    Jan 2002
    Posts
    13
    Cool thanks Fordy! I should have a dummy pc ready to go this weekend. I will play with it and see if I can get these to work. I just had a meeting today with my boss and some GM boys and we did decide not to make this program for work due to liability. But I still would like to work on it to see if maybe I can learn from it. And I want to see if my idea would have worked. If I get it to work I will post it in case you're interested in what I was doing. I thank you for all of your help!!!

    Have a great day!!

    I have to get back to studying Java...I have class tomorrow!!

    Thanks again for your help.

    Dan
    Thanks,
    Cyberpuck52

    "If you know the enemy and know yourself, you need not fear the result of a hundred battles"
    -Sun Tzu, Art of War

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Registry, Regedit
    By franse in forum C++ Programming
    Replies: 21
    Last Post: 01-29-2009, 09:57 AM
  2. Rename file problem
    By Emporio in forum C Programming
    Replies: 2
    Last Post: 06-05-2002, 10:36 AM
  3. rename() problem
    By Dimeslime in forum C Programming
    Replies: 4
    Last Post: 02-09-2002, 05:38 PM
  4. Edit a file in the registry????
    By cyberpuck52 in forum C Programming
    Replies: 2
    Last Post: 01-20-2002, 03:18 PM
  5. Registry Access
    By ExDigit in forum Windows Programming
    Replies: 3
    Last Post: 01-04-2002, 04:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21