Question Need Help With GUID in Registry

ProtekNickz

Well-known member
Joined
Oct 22, 2009
Messages
117
Location
UK
Programming Experience
1-3
Hi all, im workin on a task that will get the current computers Default Gatway, So i chose the easiest option, using the Registry, in most cases i find this with no problem at all, here's the code im using right now,

Code:
    Public sHost As String = My.Computer.Registry.GetValue _
                    ("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\Tcpip\Parameters\Interfaces\ THE GUID NEEDED HERE ", "DhcpServer", Nothing)
Which works fine, if i put My GUID in where i've stated in above code, I get the right value ect..., no what i was woundering is how would i get the program to preform this task on another Computer as their GUID will be diffrent, if their away i can do this with simplicity?

Cheers in advance :)
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,412
Location
Norway
Programming Experience
10+
It simpler to find this information using NetworkInterface class from System.Net.NetworkInformation namespace. Find network interface from GetAllNetworkInterfaces, from network interface GetIPProperties.GatewayAddresses.
 

ProtekNickz

Well-known member
Joined
Oct 22, 2009
Messages
117
Location
UK
Programming Experience
1-3
hi john, thanks for the reply, i have used that method before, i should have thought :embarrassed:, I would like to use the previous code to see if it's possible i'm sure it is, i have the following code:

Code:
Dim sGUID As Guid = GetType(Place Item Here).GUID
I have nearly got it cracked, i'm just woundering how i would reference the right item for the GUID?.

if you know a way how i coult get the right item as ive tried loads :D, then i would be greatful, if not then i'll may just revert to the GetAdapters way, I'm sure most programmers like to find new ways to do things in more way's than one as i do lol.

Cheers!.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,412
Location
Norway
Programming Experience
10+
It is also possible to use WMI and query Win32_NetworkAdapterConfiguration class for this.

Registry can be rather complex, if you encounter a Guid normally there is some other part of registry that refers to it, so you have to dig deeper to find the source, in order to find the correct target. Other times looping through a range of keys may be necessary to determine which of them may be the right one. It is not uncommon that you have to query multiple registry keys to find dependency values.
 
Top Bottom