Thread: Registry

  1. #1
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346

    Registry

    I have been trying to create a key in the registry with my program. This is what I have tried:
    Code:
    RegCreateKeyEx(HKEY_LOCAL_MACHINE, REG_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &Type)
    Each time this is returning an error. I am not sure why this is happening.

    Does anyone have any examples of opening, saving or getting information, and closing the registry so I could see how it is done. I tried this once on Windows 98, but it does not seem to be working on Windows 2000. I have been trying some of the code I found on MSDN, but it still is not working.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Does the user have access to the reg? If not, i don't think it will work.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    What error is it returning?

    (I have registry code which works on 9x/NT4 but have never tried it with 2000).
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Whenever you put REG_KEY I assume that is a #define?
    Well, It needs to be pointing into soom sub-directory. Try this...

    instead of REG_KEY...replace with

    TEXT("Software\\My Application\\Settings");

    I tryed your code on my machine with that change and it worked fine. Good Luck!
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  5. #5
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    Ok, I fixed the problem. You were right about REG_KEY. I defined it, but forgot to put the double slashes \\ I was just putting one. Thanks.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

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. Registry HowTo
    By xxxrugby in forum C Programming
    Replies: 2
    Last Post: 04-10-2005, 10:44 AM
  3. Efficient registry use?
    By bennyandthejets in forum Windows Programming
    Replies: 6
    Last Post: 09-28-2003, 06:28 PM
  4. Registry
    By gvector1 in forum C# Programming
    Replies: 0
    Last Post: 07-30-2003, 04:02 PM
  5. Registry Access
    By ExDigit in forum Windows Programming
    Replies: 3
    Last Post: 01-04-2002, 04:02 AM