473,396 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to get list of LAN computers in workgroup

Hello,
I've been working on a project and i wonder how to get list of the LAN
computer names in a tree list which are involved under the same
workgroup name?

What can be the code be?

Very thanks.

Sep 2 '07 #1
6 9823
Hi,

You can try this one.

http://www.vb-tips.com/dbpages.aspx?Search=users

Cor

"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:11**********************@d55g2000hsg.googlegr oups.com...
Hello,
I've been working on a project and i wonder how to get list of the LAN
computer names in a tree list which are involved under the same
workgroup name?

What can be the code be?

Very thanks.
Sep 2 '07 #2
On Sep 2, 6:14 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
Hi,

You can try this one.

http://www.vb-tips.com/dbpages.aspx?Search=users

Cor

"kimiraikkonen" <kimiraikkone...@gmail.comschreef in berichtnews:11**********************@d55g2000hsg.g ooglegroups.com...
Hello,
I've been working on a project and i wonder how to get list of the LAN
computer names in a tree list which are involved under the same
workgroup name?
What can be the code be?
Very thanks.- Hide quoted text -

- Show quoted text -
Hello,
Thanks for quick and helpful reply.
I looked at that link what you've sent:
http://www.vb-tips.com/ADListComputers.aspx
I've dragged ComboBox and pasted code into necessary area, but i got
following errors:

1-Type 'DirectoryEntry' is not defined
2-Type 'DirectorySearcher' is not defined
3-Type 'SearchResult' is not defined

I'm using VB.NET 2005 Express which is free version. Are these errors
because of these? Doesn't free version of Vb.NET 2005 support that
functions?

Thank you.

Sep 2 '07 #3

"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:11**********************@22g2000hsm.googlegro ups.com...
On Sep 2, 6:14 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
>Hi,

You can try this one.

http://www.vb-tips.com/dbpages.aspx?Search=users

Cor

"kimiraikkonen" <kimiraikkone...@gmail.comschreef in
berichtnews:11**********************@d55g2000hsg. googlegroups.com...
Hello,
I've been working on a project and i wonder how to get list of the LAN
computer names in a tree list which are involved under the same
workgroup name?
What can be the code be?
Very thanks.- Hide quoted text -

- Show quoted text -

Hello,
Thanks for quick and helpful reply.
I looked at that link what you've sent:
http://www.vb-tips.com/ADListComputers.aspx
I've dragged ComboBox and pasted code into necessary area, but i got
following errors:

1-Type 'DirectoryEntry' is not defined
2-Type 'DirectorySearcher' is not defined
3-Type 'SearchResult' is not defined

I'm using VB.NET 2005 Express which is free version. Are these errors
because of these? Doesn't free version of Vb.NET 2005 support that
functions?

Thank you.
You probably missed this line "You need to add a reference to
system.directoryservices and an import"

Also it proabbaly isn`t going to work cause AFAIK active directory requires
a domain
Regards

Michel


Sep 2 '07 #4
Kimiraikkonen,

http://www.vb-tips.com - not a good site to visit.

http://www.codeproject.com is far superior as doesn't have as many bugs in the
site

You can also search http://www.Planet-Source-Code.com too as there are many code
samples on there

--
Newbie Coder
(It's just a name)


"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:6C**********************************@microsof t.com...
Hi,

You can try this one.

http://www.vb-tips.com/dbpages.aspx?Search=users

Cor

"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:11**********************@d55g2000hsg.googlegr oups.com...
Hello,
I've been working on a project and i wonder how to get list of the LAN
computer names in a tree list which are involved under the same
workgroup name?

What can be the code be?

Very thanks.

Sep 3 '07 #5
Newbie Coder,

What kind of spam you are sending all the time. You are talking about bugs,
however have never told which one.

We here are no politican you know, if your site is so good, then you get
visitors enough, if not, don't tell lies.

There can be bugs in the code we give, although it is mostly completely
tested.

Cor

"Newbie Coder" <ne*********@spammeplease.comschreef in bericht
news:OB**************@TK2MSFTNGP03.phx.gbl...
Kimiraikkonen,

http://www.vb-tips.com - not a good site to visit.

http://www.codeproject.com is far superior as doesn't have as many bugs in
the
site

You can also search http://www.Planet-Source-Code.com too as there are
many code
samples on there

--
Newbie Coder
(It's just a name)


"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:6C**********************************@microsof t.com...
>Hi,

You can try this one.

http://www.vb-tips.com/dbpages.aspx?Search=users

Cor

"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:11**********************@d55g2000hsg.googleg roups.com...
Hello,
I've been working on a project and i wonder how to get list of the LAN
computer names in a tree list which are involved under the same
workgroup name?

What can be the code be?

Very thanks.

Sep 3 '07 #6
Imports System.Runtime.InteropServices

Imports System.Net

Public Class Form1

' The WNetOpenEnum function starts an enumeration of network resources or

' existing connections. You can continue the enumeration by calling the

' WNetEnumResource function.

<DllImport("mpr.dll")_

Public Shared Function WNetOpenEnum(ByVal dwScope As ResourceScope, ByVal
dwType As ResourceType, ByVal dwUsage As ResourceUsage, ByVal lpNetResource
As NETRESOURCE, ByRef lphEnum As IntPtr) As Integer

End Function

' The WNetEnumResource function continues an enumeration of network
resources

' that was started by a call to the WNetOpenEnum function.

<DllImport("mpr.dll")_

Public Shared Function WNetEnumResource(ByVal hEnum As IntPtr, ByRef
lpcCount As UInteger, ByVal lpBuffer As IntPtr, ByRef lpBufferSize As
UInteger) As Integer

End Function

' The WNetCloseEnum function ends a network resource enumeration started by
a

' call to the WNetOpenEnum function.

<DllImport("mpr.dll")_

Public Shared Function WNetCloseEnum(ByVal hEnum As IntPtr) As Integer

End Function

' Enum ResourceScope.

Public Enum ResourceScope

RESOURCE_CONNECTED = 1

RESOURCE_GLOBALNET

RESOURCE_REMEMBERED

End Enum

' Enum ResourceType.

Public Enum ResourceType

RESOURCETYPE_ANY = 0

RESOURCETYPE_DISK

RESOURCETYPE_PRINT

End Enum

' Enum ResourceDisplayType.

Public Enum ResourceDisplayType

RESOURCEDISPLAYTYPE_GENERIC = 0

RESOURCEDISPLAYTYPE_DOMAIN

RESOURCEDISPLAYTYPE_SERVER

RESOURCEDISPLAYTYPE_SHARE

End Enum

' Enum ResourceUsage.

Public Enum ResourceUsage

RESOURCEUSAGE_ALL = 0

RESOURCEUSAGE_CONNECTABLE

RESOURCEUSAGE_CONTAINER

End Enum

' Enum Error Codes.

Public Const NO_ERROR As Integer = 0

Public Const ERROR_NO_MORE_ITEMS As Integer = 259

' Structure NETRESOURCE.

<StructLayout(LayoutKind.Sequential)_

Public Class NETRESOURCE

Public dwScope As ResourceScope = 0

Public dwType As ResourceType = 0

Public dwDisplayType As ResourceDisplayType = 0

Public dwUsage As ResourceUsage = 0

Public lpLocalName As String = Nothing

Public lpRemoteName As String = Nothing

Public lpComment As String = Nothing

Public lpProvider As String = Nothing

End Class

Public Sub EnumerateServers(ByVal rScope As ResourceScope, ByVal rType As
ResourceType, ByVal rDisplayType As ResourceDisplayType, ByVal rUsage As
ResourceUsage, ByVal pNR As NETRESOURCE)

' Variables.

Dim rAPI As Integer

' API return.

Dim hEnum As IntPtr = IntPtr.Zero

' Handle to the enum.

Dim bSize As UInteger = 16384

' 16K is a good size.

Dim buffer As IntPtr = Marshal.AllocHGlobal(CInt(bSize))

' Allocate memory.

Dim eEntries As UInteger = 1

' Enumerate all possible entries

' Start an enumeration of network resources or existing connections.

rAPI = WNetOpenEnum(rScope, rType, rUsage, pNR, hEnum)

' Process errors with an application-defined error handler.

If rAPI <NO_ERROR Then

Else

Do

' Continue an enumeration of network resources.

rAPI = WNetEnumResource(hEnum, eEntries, buffer, bSize)

If rAPI <NO_ERROR Then

' Process errors with an application-defined error handler.

Return

Else

' Marshal data from an unmanaged block of memory to a

' managed object.

Marshal.PtrToStructure(buffer, pNR)

' Add lpRemoteName from NETRESOURCE to Array list.

aList.Add(pNR.lpRemoteName)

' If the NETRESOURCE structure represents a container resource,

' call the EnumerateServers function recursively.

If (ResourceUsage.RESOURCEUSAGE_CONTAINER = (pNR.dwUsage And
ResourceUsage.RESOURCEUSAGE_CONTAINER)) Then

EnumerateServers(rScope, rType, rDisplayType, rUsage, pNR)

End If

' Loop until rAPI != 259, Constant = no more items.

End If

Loop While rAPI <ERROR_NO_MORE_ITEMS

' Call WNetCloseEnum to end the enumeration.

WNetCloseEnum(hEnum)

End If

' Frees memory previously allocated from the unmanaged memory of the

' process with AllocHGlobal.

Marshal.FreeHGlobal(DirectCast(buffer, IntPtr))

End Sub

Private aList As New ArrayList()

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Button2.Enabled = False

Dim nResource As New NETRESOURCE()

EnumerateServers(ResourceScope.RESOURCE_GLOBALNET,
ResourceType.RESOURCETYPE_DISK,
ResourceDisplayType.RESOURCEDISPLAYTYPE_GENERIC,
ResourceUsage.RESOURCEUSAGE_CONTAINER, nResource)

For Each s As String In aList

If s.Substring(0, 2) = "\\" Then

Debug.WriteLine(s)

' get the asociated ip adresses for this resource

Dim ipE As IPHostEntry = Dns.GetHostEntry(s.Substring(2, s.Length - 2))

Dim IpA() As IPAddress = ipE.AddressList

For i As Integer = 0 To IpA.GetUpperBound(0)

' get the ip adresses

Debug.WriteLine(IpA(i).ToString)

Next

End If

Next

' Cleanup.

aList.Clear()

Button2.Enabled = True

End Sub

End Class

"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:11**********************@d55g2000hsg.googlegr oups.com...
Hello,
I've been working on a project and i wonder how to get list of the LAN
computer names in a tree list which are involved under the same
workgroup name?

What can be the code be?

Very thanks.

Sep 3 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: MHenry | last post by:
Hi, We were going merrily along for 6 years using this database to record all client checks that came into our office, including information about what the checks were for. Suddenly, network...
1
by: raydelex | last post by:
I am new to securing a database with logins. My questions is: I want only one database to use a new Workgroup file that I have created, not all the Access databases that I bring up under my...
3
by: Eka Gautama | last post by:
Hi All, How to retrive computer list in a workgroup? Regards Eka
3
by: zav | last post by:
Hi all. Getting stright to the point Im trying to get and set my computers workgroup name but im having litle luck, i've tryed: Environment.UserDomainName Environment.MachineName but they...
3
by: Steve | last post by:
Hi all How would i get a list of all Active Computers on a network? All I need are the computer names. Kind Regards, Steve.
1
by: Bilge TUTAK | last post by:
Hi, I want to find the list of the computer names in a workgroup or in a domain. Is there a way to do this in VB.NET? Thanx
1
by: haren | last post by:
i am working with a LAN of 20 computers with win -98 and win-xp,my problem is that when i try to see workgroup computers from my pc with win xp,sometimes it shows the all compute in the same...
17
by: John Salerno | last post by:
Let me see if this question even makes sense...I'm reading Core Python Programming and I jumped ahead to the more specific topics like network programming. I plan to follow along with the example...
6
by: belias | last post by:
So...here we go. I'm having an issue with one computer on a network not being able to ping other computers by name. I've spent the last day searching similar issues and I've tried all the steps...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.