code alteration -Help Needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ananth
    New Member
    • Nov 2006
    • 75

    code alteration -Help Needed

    Hi All,
    I have a code that generates list of installed softwares available on the pc but the code works fine when written in a console application project in visual basic 2005.

    How can the same code be used to generate a list of software information using a button click available in an ordinary windows application project

    the code is as follows

    Dim hklm As Microsoft.Win32 .RegistryKey
    Dim software As Microsoft.Win32 .RegistryKey
    Dim subkeys() As String
    Dim keyname As String

    hklm = My.Computer.Reg istry.LocalMach ine
    software = hklm.OpenSubKey ("SOFTWARE\Micr osoft\Windows\C urrentVersion\U ninstal l")
    subkeys = software.GetSub KeyNames()

    For Each keyname In subkeys
    Console.WriteLi ne(keyname)
    Next
    MsgBox(subkeys)

    Console.WriteLi ne("press ENTER to exit")
    Console.ReadLin e()
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by ananth
    Hi All,
    I have a code that generates list of installed softwares available on the pc but the code works fine when written in a console application project in visual basic 2005.

    How can the same code be used to generate a list of software information using a button click available in an ordinary windows application project

    the code is as follows

    Dim hklm As Microsoft.Win32 .RegistryKey
    Dim software As Microsoft.Win32 .RegistryKey
    Dim subkeys() As String
    Dim keyname As String

    hklm = My.Computer.Reg istry.LocalMach ine
    software = hklm.OpenSubKey ("SOFTWARE\Micr osoft\Windows\C urrentVersion\U ninstal l")
    subkeys = software.GetSub KeyNames()

    For Each keyname In subkeys
    Console.WriteLi ne(keyname)
    Next
    MsgBox(subkeys)

    Console.WriteLi ne("press ENTER to exit")
    Console.ReadLin e()
    You could output to a label on the form or a textbox with scroll bars or even a message box if there is not too much info

    Code:
    Dim result As String
    For Each keyname In subkeys
    result = keyname & vbCrLf
    Next
    MsgBox result
    MsgBox(subkeys)

    Comment

    • ananth
      New Member
      • Nov 2006
      • 75

      #3
      Originally posted by willakawill
      You could output to a label on the form or a textbox with scroll bars or even a message box if there is not too much info

      Code:
      Dim result As String
      For Each keyname In subkeys
      result = keyname & vbCrLf
      Next
      MsgBox result
      MsgBox(subkeys)

      Hi Willakawill,
      I tried your code but the it is not working and generating an error in the corresponding line.

      subkeys = software.GetSub KeyNames()

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        Originally posted by ananth
        Hi Willakawill,
        I tried your code but the it is not working and generating an error in the corresponding line.

        subkeys = software.GetSub KeyNames()
        That's not my code. That is the code that you submitted.
        Please post the altered code

        Comment

        Working...