Click to See Complete Forum and Search --> : C# Remote Registry problem


dfb78
January 17th, 2003, 02:06 PM
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

pareshgh
January 17th, 2003, 02:10 PM
could you plz add your context code also

?

Paresh

dfb78
January 17th, 2003, 02:31 PM
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.

pareshgh
January 17th, 2003, 02:36 PM
yes you are right here,
Value Names that contain Reg_Multi_Sz Value Data.
check out that. also.

Paresh

dfb78
January 17th, 2003, 02:45 PM
Well that's the issue. I know what needs to be done, I just don't know HOW to do it.

pareshgh
January 18th, 2003, 02:57 AM
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

dfb78
January 18th, 2003, 09:03 AM
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!

pareshgh
January 19th, 2003, 01:44 AM
you could try solving your problem
Here (http://www.gotdotnet.com/Community/MessageBoard/MessageBoard.aspx?id=6)

dfb78
January 19th, 2003, 09:08 AM
Thanks...that one is me too. ;P Finally got it.

pareshgh
February 17th, 2003, 06:11 PM
could you post your sample. I am interested in looking at your code.
thanx and appreciate it
Paresh

dfb78
February 17th, 2003, 09:55 PM
I ended up using the recommended code snip from the post here (http://www.gotdotnet.com/community/messageboard/Thread.aspx?id=66097&Page=1).

pareshgh
February 18th, 2003, 03:04 PM
oh ! that's nice. thanx you already there :-)
:D

Paresh