CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97

    Question C# Remote Registry problem

    I've created an application that connects to a remote box's registry. I can successfully connect, and I even have a combo box that auto-populates each time you drill down farther into the registry with new subkeys. The problem in a list box that I populate with the Value Names each time you drill down into a subkey. When you click on the Value Name, the Value Data should get displayed in a text box in the same form. Unfortunately, sometimes the text box displays "System.String[]". I understand that not all registry entries are string values, and so it is simply populating the text box with what it knows. I just don't know how to do it RIGHT! ;P Can anyone help? The code for the method I currently have all screwed up is below:

    ==============================================
    private void lstbxRegValueNames_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    try
    {
    string getVal = subKey.GetValue(lbxReg.SelectedItem.ToString()).ToString();
    txtKeyValueData.Text = getVal.ToString();
    }
    catch(Exception eGetValueData)
    {
    MessageBox.Show(eGetVal.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }
    ==============================================

    I know there are just WAY too many ToString()'s in there, but it is the only way I could even get the values to display without throwing an exception in the first place. ANY help would be greatly appreciated.

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    could you plz add your context code also

    ?

    Paresh

  3. #3
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    Sorry, I'm not sure I understand. The only thing that should be relevant is the lbxReg listbox and the subKey (type: RegistryKey) right?

    I think it has to do with the Value Names that contain Reg_Multi_Sz Value Data.

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    yes you are right here,
    Value Names that contain Reg_Multi_Sz Value Data.
    check out that. also.

    Paresh

  5. #5
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    Well that's the issue. I know what needs to be done, I just don't know HOW to do it.

  6. #6
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    there may be another issue also. like

    1) are you getting an administrator access for that machine
    2) since registery and all access requires the user to be an administrative login on that machine.


    I had the similliar problem in past while i was trying to make a remote reboot machine. since it was not possible then i just made it loginable with administrative.

    since the empty list either indicates exception or you are getting nothing. you should check at least you get to that machine or not..


    Paresh

  7. #7
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    Like I said, I can do EVERYTHING on the remote box, except gather Value Data for non-string types I can connect, drill-down, display all the keys, etc. The ONLY problem here is displaying Value Data for Value Names that do not hold string values. I am not sure how to get that information, so I have resorted to a lot of string conversions, and I am sure there is something incorrect there. I just need to know the correct type to use (maybe an example) to get what I want. For instance, if I have already drilled down to the key I need information from, and want to get the Value Data from a Value Name called "Info" or something, I am doing this:

    object valueData = myKey.GetValue("Info");
    MessageBox.Show(valueData.ToString());

    This is obviously wrong, because I am 100% positive the Value Name holds data I am simply trying to find out how to gather that data once I am at this point.

    Thanks!

  8. #8
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    you could try solving your problem
    Here

  9. #9
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    Thanks...that one is me too. ;P Finally got it.

  10. #10
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    could you post your sample. I am interested in looking at your code.
    thanx and appreciate it
    Paresh

  11. #11
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    I ended up using the recommended code snip from the post here.

  12. #12
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    oh ! that's nice. thanx you already there :-)


    Paresh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured