473,738 Members | 10,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9845
Hi,

You can try this one.

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

Cor

"kimiraikko nen" <ki************ *@gmail.comschr eef in bericht
news:11******** **************@ d55g2000hsg.goo glegroups.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

"kimiraikko nen" <kimiraikkone.. .@gmail.comschr eef in berichtnews:11* *************** ******@d55g2000 hsg.googlegroup s.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 'DirectorySearc her' 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

"kimiraikko nen" <ki************ *@gmail.comschr eef in bericht
news:11******** **************@ 22g2000hsm.goog legroups.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.comschr eef in
berichtnews:11 *************** *******@d55g200 0hsg.googlegrou ps.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 'DirectorySearc her' 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.director yservices 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******** *************** ***********@mic rosoft.com...
Hi,

You can try this one.

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

Cor

"kimiraikko nen" <ki************ *@gmail.comschr eef in bericht
news:11******** **************@ d55g2000hsg.goo glegroups.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*********@sp ammeplease.coms chreef in bericht
news:OB******** ******@TK2MSFTN GP03.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******** *************** ***********@mic rosoft.com...
>Hi,

You can try this one.

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

Cor

"kimiraikkonen " <ki************ *@gmail.comschr eef in bericht
news:11******* *************** @d55g2000hsg.go oglegroups.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

' WNetEnumResourc e function.

<DllImport("mpr .dll")_

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

End Function

' The WNetEnumResourc e function continues an enumeration of network
resources

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

<DllImport("mpr .dll")_

Public Shared Function WNetEnumResourc e(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(B yVal hEnum As IntPtr) As Integer

End Function

' Enum ResourceScope.

Public Enum ResourceScope

RESOURCE_CONNEC TED = 1

RESOURCE_GLOBAL NET

RESOURCE_REMEMB ERED

End Enum

' Enum ResourceType.

Public Enum ResourceType

RESOURCETYPE_AN Y = 0

RESOURCETYPE_DI SK

RESOURCETYPE_PR INT

End Enum

' Enum ResourceDisplay Type.

Public Enum ResourceDisplay Type

RESOURCEDISPLAY TYPE_GENERIC = 0

RESOURCEDISPLAY TYPE_DOMAIN

RESOURCEDISPLAY TYPE_SERVER

RESOURCEDISPLAY TYPE_SHARE

End Enum

' Enum ResourceUsage.

Public Enum ResourceUsage

RESOURCEUSAGE_A LL = 0

RESOURCEUSAGE_C ONNECTABLE

RESOURCEUSAGE_C ONTAINER

End Enum

' Enum Error Codes.

Public Const NO_ERROR As Integer = 0

Public Const ERROR_NO_MORE_I TEMS As Integer = 259

' Structure NETRESOURCE.

<StructLayout(L ayoutKind.Seque ntial)_

Public Class NETRESOURCE

Public dwScope As ResourceScope = 0

Public dwType As ResourceType = 0

Public dwDisplayType As ResourceDisplay Type = 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 EnumerateServer s(ByVal rScope As ResourceScope, ByVal rType As
ResourceType, ByVal rDisplayType As ResourceDisplay Type, 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.AllocHG lobal(CInt(bSiz e))

' Allocate memory.

Dim eEntries As UInteger = 1

' Enumerate all possible entries

' Start an enumeration of network resources or existing connections.

rAPI = WNetOpenEnum(rS cope, 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 = WNetEnumResourc e(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.PtrToSt ructure(buffer, pNR)

' Add lpRemoteName from NETRESOURCE to Array list.

aList.Add(pNR.l pRemoteName)

' If the NETRESOURCE structure represents a container resource,

' call the EnumerateServer s function recursively.

If (ResourceUsage. RESOURCEUSAGE_C ONTAINER = (pNR.dwUsage And
ResourceUsage.R ESOURCEUSAGE_CO NTAINER)) Then

EnumerateServer s(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(h Enum)

End If

' Frees memory previously allocated from the unmanaged memory of the

' process with AllocHGlobal.

Marshal.FreeHGl obal(DirectCast (buffer, IntPtr))

End Sub

Private aList As New ArrayList()

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

Button2.Enabled = False

Dim nResource As New NETRESOURCE()

EnumerateServer s(ResourceScope .RESOURCE_GLOBA LNET,
ResourceType.RE SOURCETYPE_DISK ,
ResourceDisplay Type.RESOURCEDI SPLAYTYPE_GENER IC,
ResourceUsage.R ESOURCEUSAGE_CO NTAINER, 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.GetHostEntr y(s.Substring(2 , s.Length - 2))

Dim IpA() As IPAddress = ipE.AddressList

For i As Integer = 0 To IpA.GetUpperBou nd(0)

' get the ip adresses

Debug.WriteLine (IpA(i).ToStrin g)

Next

End If

Next

' Cleanup.

aList.Clear()

Button2.Enabled = True

End Sub

End Class

"kimiraikko nen" <ki************ *@gmail.comschr eef in bericht
news:11******** **************@ d55g2000hsg.goo glegroups.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
6043
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 computers cannot access the database. The message is...
1
2532
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 system login. Can this be done? Thanks
3
5718
by: Eka Gautama | last post by:
Hi All, How to retrive computer list in a workgroup? Regards Eka
3
8958
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 only retreive the local machine name.
3
3873
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
4097
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
1844
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 workgroup some times not,i can ping the all computer in my workgroup,also i can search and access. why it shows sometimes and not othertime pls anyone suggest me
17
5566
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 in that chapter and create a socket connection between my desktop and laptop. However, these two computers are already connected on my home network (using the Windows Network Setup Wizard), so I was wondering if this will have any effect on what...
6
4206
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 recommended. If anyone has some suggestions, I'd love to give them a try - this is driving me nuts!! I am connected via wired-LAN to a Linksys WRT-600N router; there are 4 other computers on the network. The other 3 computers are working perfectly...
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9263
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8210
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.