Thread: Registry

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

    Exclamation Registry

    I am trying to get my program to load its startup information from the Windows registry. I can load integers correctly by using the following code:

    RegEnumValue(hKey, Index, Buffer, &BufSize, NULL, &Type, &Data, &Size);

    When I try to get the value of a string like this:

    RegEnumValue(hKey, 5, Buffer, &BufSize, NULL, &Type, &Data, &Size);
    strcpy(Option.FontName, Data);

    I get an error message.

    How can I load a string from the registry?
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  2. #2
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    Code:
    const char *keyName = "myStringValueName";
    char *buffer = new char[256];
    DWORD bufferSize = 256;
    RegQueryValueEx(globalKey, keyName, NULL, NULL, (LPBYTE)buffer, &bufferSize);
    And of course,
    Code:
    delete [] buffer;
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  3. #3
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    Thanks for your help.

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