Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I understand the use of the Shell / Process.Start function, but what if I don't know the path (only the name) of the program I am trying to start? Is there another function that can perform a search and return the path? Thanks in advance.
Posted

Forgive the onslaught of questions, but I'm a novice. I've got little experience with the registry and I'm not sure about the snytax of the Registry class.

 

Microsoft.Win32.Registry.LocalMachine.ToString returns the string:

HKEY_LOCAL_MACHINE [0x80000002]

 

Anyway, I'm pretty sure that bit is irrelevant. How do I use Microsoft.Win32.Registry to query? What's the proper syntax and what data type will it return? I'm assuming that "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" is some sort of arguement.

 

Any working examples I can test and practice with?

 

Thanks again.

 

-Matt

  • Leaders
Posted

here's a quick example , add a listbox and a button to a form , then put this in the button_click event ...

       Dim rKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths", False)
       Dim itemKey As Microsoft.Win32.RegistryKey

       Dim strItems As String() = rKey.GetSubKeyNames '/// get all the application name keys in the app paths section.
       Dim strPath As String
       For Each strPath In strItems
           itemKey = rKey.OpenSubKey(strPath)
           Dim appPath As String = Convert.ToString(itemKey.GetValue(""))  '/// default = ""
           If Not appPath.Length = 0 Then
               ListBox1.Items.Add(appPath) '/// this is a valid exe path for an exe ( all registered exes )  thats installed on your pc
           Else
               appPath = Convert.ToString(itemKey.GetValue("path"))  '/// some files have a folder path key , but no default value.
               If Not appPath.Length = 0 Then '/// sometimes there's no path either here.
                   appPath += "\" & strPath
                   ListBox1.Items.Add(appPath)
               End If
           End If
       Next

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...