Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. can't figure what's wrong with this code

can't figure what's wrong with this code

Scheduled Pinned Locked Moved C#
windows-adminhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pyro Joe
    wrote on last edited by
    #1

    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]

    C L 2 Replies Last reply
    0
    • P Pyro Joe

      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]

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      pyrojoe wrote: int repeat = history.SubKeyCount SubKeyCount won't get you the number of URL values, you need ValueCount. 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 about for 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

      1 Reply Last reply
      0
      • P Pyro Joe

        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]

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • L leppie

          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

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          leppie 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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups