DubbleEagle
asked on
Get workgroup name(s) in LAN
I have been searching the internet for 2 days now, and I can't find any good line(s) of code about how to retrieve the workgroup name I am connected to. Or even better: getting all workgroups within the local network (LAN). I am using Windows XP (Home edition) but it would be nice if it works for all versions of windows.
Code should be in VB.Net !
Thanks
Code should be in VB.Net !
Thanks
ASKER
Ronald, I have seen this topic before, and I got some problems testing it. If I insert the code in VB.Net, I get some errors, including the line
Dim wshShell As New IWshShell_Class
which is (in my opinion) part of the code for retrieving a registry value. IWshShell_Class is not known by my compiler (maybe I should add a reference?).
Also, if I check my registry (via regedit), I cannot find the subdirectory "VDX" in HKEY_LOCAL_MACHINE\System\ CurrentCon trolSet\Se rvices\
Maybe usefull information (?): I am using Visual Studio .Net 2003 Professional
Dim wshShell As New IWshShell_Class
which is (in my opinion) part of the code for retrieving a registry value. IWshShell_Class is not known by my compiler (maybe I should add a reference?).
Also, if I check my registry (via regedit), I cannot find the subdirectory "VDX" in HKEY_LOCAL_MACHINE\System\
Maybe usefull information (?): I am using Visual Studio .Net 2003 Professional
Imports System
Imports System.Security
Private Function GetUserName() As String
Return Principal.WindowsIdentity. GetCurrent .Name()
' This will return 'domain(or workgroup)\username' so just parse the Info
End Function
Imports System.Security
Private Function GetUserName() As String
Return Principal.WindowsIdentity.
' This will return 'domain(or workgroup)\username' so just parse the Info
End Function
ASKER
I tried the code you suggested (with msgbox() instead of return), but it gives me the following information:
"Computername/CurrentUserN ame"
The name of the workgroup is not listed :(
"Computername/CurrentUserN
The name of the workgroup is not listed :(
ASKER
I'll try out that topic, and will let you know if it worked :-)
ASKER
Ok, I tried everything listed there. Good thing is: I don't need the workgroup name to get all workstations/servers from the network. Bad thing is, that I still can't get the name of the workgroup I'm connected to.
I would like to create a tree-structure of all workgroups, with all computers connected to them (like windows-explorer: my-network-connections, microsoft-windows-network - from there, you get a tree view of the entire network)
If that shouldn't be possible, at least I would like to retrieve the name of my workgroup
I would like to create a tree-structure of all workgroups, with all computers connected to them (like windows-explorer: my-network-connections, microsoft-windows-network - from there, you get a tree view of the entire network)
If that shouldn't be possible, at least I would like to retrieve the name of my workgroup
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thnx, this works perfect!
https://www.experts-exchange.com/questions/20952847/Workgroup-Name.html