can't figure what's wrong with this code
-
basically, I want to add the url history of ie, each one onto a new line. here's the code I have written thus far. I am druly bedazzled as to why it won't work. thanks for the help. ps, if you know a better way to add the registry values (all that exist in the registry key) onto new lines in a multiline textbox, that is much simpler than my confusing integers way (the rookie way!) of doing it, please let me know. I don't like being ignorant. anyways, thanks and here's the code: [CODE] RegistryKey home_page_open = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main"); this.textBox3.Text = home_page_open.GetValue("Start Page").ToString(); //load history into textbox RegistryKey history = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs"); int repeat = history.SubKeyCount; int init = 1; while (repeat > 0) { textBox4.Text += "\r\n" + history.GetValue("url" + init.ToString()).ToString(); init ++; repeat --; } [/CODE]
-
basically, I want to add the url history of ie, each one onto a new line. here's the code I have written thus far. I am druly bedazzled as to why it won't work. thanks for the help. ps, if you know a better way to add the registry values (all that exist in the registry key) onto new lines in a multiline textbox, that is much simpler than my confusing integers way (the rookie way!) of doing it, please let me know. I don't like being ignorant. anyways, thanks and here's the code: [CODE] RegistryKey home_page_open = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main"); this.textBox3.Text = home_page_open.GetValue("Start Page").ToString(); //load history into textbox RegistryKey history = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs"); int repeat = history.SubKeyCount; int init = 1; while (repeat > 0) { textBox4.Text += "\r\n" + history.GetValue("url" + init.ToString()).ToString(); init ++; repeat --; } [/CODE]
pyrojoe wrote: int repeat = history.SubKeyCount
SubKeyCount
won't get you the number of URL values, you needValueCount
. A SubKey, as you might guess from other code you've got, is the directory-like path to get to the values you are looking for. Also, your loop is a little crazy, you need to learn aboutfor
loops. I suggest changing your loop to:int count = history.ValueCount;
for(int i = 1; i<=count; i++)
{
// Do stuff with history.GetValue("url" + i.ToString()));
}Does this help?
Do you want to know more? WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
-
basically, I want to add the url history of ie, each one onto a new line. here's the code I have written thus far. I am druly bedazzled as to why it won't work. thanks for the help. ps, if you know a better way to add the registry values (all that exist in the registry key) onto new lines in a multiline textbox, that is much simpler than my confusing integers way (the rookie way!) of doing it, please let me know. I don't like being ignorant. anyways, thanks and here's the code: [CODE] RegistryKey home_page_open = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main"); this.textBox3.Text = home_page_open.GetValue("Start Page").ToString(); //load history into textbox RegistryKey history = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs"); int repeat = history.SubKeyCount; int init = 1; while (repeat > 0) { textBox4.Text += "\r\n" + history.GetValue("url" + init.ToString()).ToString(); init ++; repeat --; } [/CODE]
pyrojoe wrote: CreateSubKey Shouldnt you rather be opening them? I suspect its a bit late now.... :doh: top secret
Download xacc-ide 0.0.3 now!
See some screenshots -
pyrojoe wrote: CreateSubKey Shouldnt you rather be opening them? I suspect its a bit late now.... :doh: top secret
Download xacc-ide 0.0.3 now!
See some screenshotsleppie wrote: Shouldnt you rather be opening them? It has been a while since I dug around in the Windows Registry, but IIRC, the CreateSubKey will create a new sub key or open an existing one - kind of like a 2-for-1 deal in the supermarket. :rolleyes:
Do you want to know more? WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums