locked
Searching for registry value and getting value RRS feed

  • Question

  • Hi

    I need to be able to search a certain key in the registry:-

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles

    And look for any profiles in this list which contain a specific word in the Description field

    And then get the full registry path for the profile which match

    Entries in this location look similar to below e.g. they have a GUID value, and there can be several of them

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\{85944595-D1D1-48CF-9D22-0D96086C8BFE}

    So using example above if the above key had a Description value which matched what I was looking for then I would need it to return the full key including the GUID

    Any thoughts please

    Thanks


    Darren Rose

    Thursday, March 5, 2020 9:49 PM

Answers

  • Okay, thanks - didn't know about that

    Will try and find some sample code to play with


    For a starting code, just a test to enumerate them :

            ' Add reference to : c:\windows\system32\netprofm.dll
            ' Add : Imports NETWORKLIST
    
            Dim nlm As INetworkListManager = New NetworkListManager()
            Dim networks As IEnumNetworks = nlm.GetNetworks(NLM_ENUM_NETWORK.NLM_ENUM_NETWORK_ALL)
            For Each network As INetwork In networks
                Dim sName As String = network.GetName()
                Dim sCategory As String = network.GetCategory().ToString()
                Dim sGuid As String = network.GetNetworkId().ToString()
                Dim sConnected As String = (If((network.IsConnected = True), "(connected)", "(disconnected)"))
                Console.WriteLine("Name : {0} - {1} - {2} {3}", sName, sGuid, sCategory, sConnected)
            Next

    • Marked as answer by wingers Tuesday, March 10, 2020 2:15 PM
    Tuesday, March 10, 2020 12:30 PM

All replies

  • Hello,

    I need to make sure my understanding is correct.

    Take the following figure as an example. Do you want to find all the GUID values in the profiles, their description includes Fast_4702, and finally return their full path?

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 10, 2020 2:13 AM
  • Yes get full paths for all GUID's where Description = FAST_4702 (in your case)

    Darren Rose

    Tuesday, March 10, 2020 10:59 AM
  • You don't need to read registry

    You get those values with IEnumNetworks interface

    Tuesday, March 10, 2020 11:45 AM
  • You don't need to read registry

    You get those values with IEnumNetworks interface

    But I need to know registry full path so I can then set Cateogry to 1

    Darren Rose

    Tuesday, March 10, 2020 11:54 AM
  • You don't need to read registry

    You get those values with IEnumNetworks interface

    But I need to know registry full path so I can then set Cateogry to 1
    You just call INetwork.SetCategory
    Tuesday, March 10, 2020 12:15 PM
  • Okay, thanks - didn't know about that

    Will try and find some sample code to play with

    Thanks


    Darren Rose

    Tuesday, March 10, 2020 12:26 PM
  • Okay, thanks - didn't know about that

    Will try and find some sample code to play with


    For a starting code, just a test to enumerate them :

            ' Add reference to : c:\windows\system32\netprofm.dll
            ' Add : Imports NETWORKLIST
    
            Dim nlm As INetworkListManager = New NetworkListManager()
            Dim networks As IEnumNetworks = nlm.GetNetworks(NLM_ENUM_NETWORK.NLM_ENUM_NETWORK_ALL)
            For Each network As INetwork In networks
                Dim sName As String = network.GetName()
                Dim sCategory As String = network.GetCategory().ToString()
                Dim sGuid As String = network.GetNetworkId().ToString()
                Dim sConnected As String = (If((network.IsConnected = True), "(connected)", "(disconnected)"))
                Console.WriteLine("Name : {0} - {1} - {2} {3}", sName, sGuid, sCategory, sConnected)
            Next

    • Marked as answer by wingers Tuesday, March 10, 2020 2:15 PM
    Tuesday, March 10, 2020 12:30 PM
  • Thanks Castorix31 - that has given me plenty to work with :)

    Darren Rose

    Tuesday, March 10, 2020 2:15 PM