dropdown list? / reg? problems

This is a discussion on dropdown list? / reg? problems within the Windows Programming forums, part of the Platform Specific Boards category; so i'm trying to read in values from the registry and add them to a dropdown list for the user ...

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    dropdown list? / reg? problems

    so i'm trying to read in values from the registry and add them to a dropdown list for the user to select one. i've created a loop to add the values to the list, but for some reason it only reads in the initial value.? so if i initialize my counter to 0, it reads in the key indexed at 0, if i initialize it to 1, it reads in the key indexed at 1, etc. i know it doesn't get caught in an infinite loop, because it goes through the loop the correct number of times (yes i'm adhd and wanted to repeat myself (not literally)). it baffles me here's the code:
    Code:
    do {
             regresult = RegEnumKeyEx(hkey, counter, data, &size, 0, 0, 0, 0);
             if (regresult != ERROR_NO_MORE_ITEMS)
                 SendMessage(GetDlgItem(hwnd, ID_CMBBOX), CB_ADDSTRING, 0, (LPARAM)(LPCSTR)data);
             //counter = counter+1;
             //counter += 1;
             ++counter;
             i = 0;
             /* if i dont null out the string, the original value gets added X number of times..? */
             while (data[i] != 0)
             {    data[i] = 0;    }
         } while (regresult != ERROR_NO_MORE_ITEMS);
    so uh...anyone know whats wrong? lol
    btw, the one value that DOES get read in, IS added to the dropdown list.
    Last edited by willc0de4food; 02-06-2006 at 05:56 PM.
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Because the lpcName argument is an [in, out] parameter, it updates the value in the size variable after each call. This means you must reset it every time.
    Code:
     size = sizeof(data);
             regresult = RegEnumKeyEx(hkey, counter, data, &size, 0, 0, 0, 0);

  3. #3
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    fricken sweet.

    lol thanks.
    Registered Linux User #380033. Be counted: http://counter.li.org

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help! Placement of nodes in a Linked List
    By lostmyshadow in forum C Programming
    Replies: 6
    Last Post: 12-17-2007, 12:21 PM
  2. Replies: 6
    Last Post: 03-02-2005, 01:45 AM
  3. problem with structures and linked list
    By Gkitty in forum C Programming
    Replies: 6
    Last Post: 12-12-2002, 05:40 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

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