Nov 15th, 2005, 10:51 PM
#1
Thread Starter
Member
[ask] detect all computer in network
hello,
can anybody teach me how to do that(I'm newbie in network programming), to detect all the computer name's list in the network(LAN with(out) domain) and also the IP's list of the computers, thanks before
Nov 16th, 2005, 01:21 AM
#2
Re: [ask] detect all computer in network
Well.. theres lots of ways I would imagine.. but we need an idea of your network... do you use Active Directory? Is this being ran on a server or on a client machine?
Nov 16th, 2005, 02:22 AM
#3
Thread Starter
Member
Re: [ask] detect all computer in network
maybe from just the basic LAN, just simple networking without the server, so the program just detecting all the comp in LAN
Nov 16th, 2005, 02:42 AM
#4
Re: [ask] detect all computer in network
I couldnt find any info on the subject when searching around. Looks like you might have to resort to api...
I did find this one link of a VB6 project that uses a couple classes in order to list the computers in a domain using API, of course it would need to be converted to .NET code..
http://www.planet-source-code.com/vb...15174&lngWId=1
Nov 16th, 2005, 03:09 AM
#5
Thread Starter
Member
Re: [ask] detect all computer in network
well, thanks for the effort to help me, i'll try to look at it then
Nov 16th, 2005, 04:39 AM
#6
Re: [ask] detect all computer in network
Perhaps you could also utilize the output of Net View or use WMI...
Nov 16th, 2005, 08:26 PM
#7
Thread Starter
Member
Re: [ask] detect all computer in network
Originally Posted by
dee-u
Perhaps you could also utilize the output of Net View or use WMI...
what is Net View and WMI, and how could I use that for detecting comps in network ?
Nov 16th, 2005, 08:42 PM
#8
Re: [ask] detect all computer in network
You would need to write some unmanaged code suing the NetServerEnum API. I have some code that does it but its in VB6. I havent converted it to VB.NET yet as I havent had the need. Maybe if no one else has a solution I will make an effort to convert it.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 08:43 PM
#9
Re: [ask] detect all computer in network
Originally Posted by
RobDog888
You would need to write some unmanaged code suing the NetServerEnum API. I have some code that does it but its in VB6. I havent converted it to VB.NET yet as I havent had the need. Maybe if no one else has a solution I will make an effort to convert it.
Go Rob!
Nov 16th, 2005, 08:45 PM
#10
Re: [ask] detect all computer in network
Well, basically I'm waiting for John to post stating that it can be done easily with a certain class in .NET. I think I'll search until then. Maybe I'll beat him to it.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 08:50 PM
#11
Re: [ask] detect all computer in network
so far I found a calss to determine if your local system is connected to a network or not.
VB Code:
MessageBox.Show(System.Windows.Forms.SystemInformation.Network.ToString())
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 09:09 PM
#12
Re: [ask] detect all computer in network
Guess I'll have a go at it then.
What is "LMCSTR"? Its in an API declaration.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 09:21 PM
#13
Re: [ask] detect all computer in network
I think its something like this?
VB Code:
<MarshalAs(UnmanagedType.LPStr)> _
Private Const LMCSTR As Int32 = LPCSTR
<MarshalAs(UnmanagedType.LPStr)> _
Private Const LPCSTR As Int32 = UnmanagedType.LPStr
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 10:22 PM
#14
Thread Starter
Member
Re: [ask] detect all computer in network
????
sorry but im really2 confused
Last edited by paul_heru; Nov 16th, 2005 at 10:35 PM .
Nov 16th, 2005, 10:49 PM
#15
Re: [ask] detect all computer in network
I am about 75% way complete but I have run into a couple of issues converting the calls. I dont think I will be done tonight. Should be able to post it tomorrow.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 10:56 PM
#16
Re: [ask] detect all computer in network
Gotta love those API call conversions... (remember.. byval or byref )
Nov 16th, 2005, 11:09 PM
#17
Re: [ask] detect all computer in network
Hey gig! Mind if I throw some APIs at you?
VB Code:
<StructLayout(LayoutKind.Sequential)> _
Public Structure SERVER_INFO_100
<MarshalAs(UnmanagedType.LPStr)> _
Friend sv100_platform_id As Integer
<MarshalAs(UnmanagedType.LPStr)> _
Friend sv100_name As Integer
End Structure
Private Declare Auto Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pTo As Integer, ByRef uFrom As Integer, ByVal lSize As Integer)
Private Declare Auto Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pTo As String, ByRef uFrom As Integer, ByVal lSize As Integer)
Private Sub Button1_Click(blah, blah, blah....
Dim se100 As SERVER_INFO_100
Dim bufptr As Integer
Dim nStructSize As Integer
Dim Cnt As Integer
'...
CopyMemory(se100, bufptr + (nStructSize * Cnt), nStructSize) 'ERROR
Error is
D:\Development\Tips .NET\Network Neighborhood\clsNetwork.vb(61): Overload resolution failed because no accessible 'CopyMemory' can be called with these arguments:
'Declare Auto Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pTo As String, ByRef uFrom As Integer, lSize As Integer)': Value of type 'Network_Neighborhood.clsNetwork.SERVER_INFO_100' cannot be converted to 'String'.
'Declare Auto Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pTo As Integer, ByRef uFrom As Integer, lSize As Integer)': Value of type 'Network_Neighborhood.clsNetwork.SERVER_INFO_100' cannot be converted to 'Integer'.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 11:23 PM
#18
Re: [ask] detect all computer in network
First instinct would be to change "ByRef uFrom" to "ByVal uFrom" ... (it worked before hehehe)... but id have to search for examples of that, because ive never used it before..
Nov 16th, 2005, 11:29 PM
#19
Re: [ask] detect all computer in network
I think that part is ok but the error message shows that its the conversion of the structure to a string or integer.
SERVER_INFO_100' cannot be converted to 'String'
SERVER_INFO_100' cannot be converted to 'Integer'
I overloaded the API call to see if either would work but nada.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 11:35 PM
#20
Re: [ask] detect all computer in network
Hey rob.. check out this link... has sample of vb.net code using it.. lists the declaration they use as well as their server_info_100 structure
http://www.eggheadcafe.com/forums/Fo...11135&INTID=14
***EDIT -Whoops.. forgot its the copymemory that the problem is at....
Last edited by gigemboy; Nov 16th, 2005 at 11:50 PM .
Nov 16th, 2005, 11:42 PM
#21
Re: [ask] detect all computer in network
Cool! I dont like the way they do it but I will use the types for the APIs. I was sooo close. Intptr intstead of Integer. Shouldnt be long now.
Also, Marshal.SizeOf instead of LenB
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 16th, 2005, 11:46 PM
#22
Re: [ask] detect all computer in network
Looks like they dont even use CopyMemory. The use a DirectCast -
VB Code:
se101 = DirectCast(Marshal.PtrToStructure(New IntPtr(bufptr.ToInt32 + (nStructSize * cnt)), GetType(SERVER_INFO_101)), SERVER_INFO_101)
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 17th, 2005, 01:46 AM
#23
Re: [ask] detect all computer in network
I got the class file to work now. Its similar to the link gig posted. I'll attach it if you want. I think I will make a little Net Neighborhood program out of it just for fun.
Attached Files
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 17th, 2005, 02:25 AM
#24
Thread Starter
Member
Re: [ask] detect all computer in network
Nov 17th, 2005, 04:40 AM
#25
Re: [ask] detect all computer in network
Nov 17th, 2005, 05:15 AM
#26
Hyperactive Member
Re: [ask] detect all computer in network
for the without domain bit:
from google groups
VB Code:
'
'Imports system.runtime.interopservices
Dim WithEvents b As New Button
Dim lv As New ListView
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
b.Location = New Point((Me.ClientSize.Width - b.Width) \ 2, Me.ClientSize.Height - 60)
b.Text = "list"
lv.View = View.Details
lv.Columns.Add("Workgroup Computers", 300, HorizontalAlignment.Left)
lv.Dock = DockStyle.Top
lv.Height = Me.ClientSize.Height - 80
Me.Controls.Add(lv)
Me.Controls.Add(b)
AddHandler b.Click, AddressOf b_click
End Sub
Declare Unicode Function NetServerEnum Lib "Netapi32.dll" _
(ByVal Servername As Integer, ByVal level As Integer, _
ByRef buffer As Integer, ByVal PrefMaxLen As Integer, _
ByRef EntriesRead As Integer, ByRef TotalEntries As Integer, _
ByVal ServerType As Integer, ByVal DomainName As String, _
ByRef ResumeHandle As Integer) As Integer
Declare Function NetApiBufferFree Lib "Netapi32.dll" _
(ByVal lpBuffer As Integer) As Integer
Structure Computer_info_101
Public Platform_ID As Integer
<MarshalAsAttribute(UnmanagedType.LPWStr)> Public Name As String
Public Version_Major As Integer
Public Version_Minor As Integer
Public Type As Integer
<MarshalAsAttribute(UnmanagedType.LPWStr)> Public Comment As String
End Structure
Private Const SV_TYPE_SERVER As Integer = &H2 ' All Servers
Private Sub ListCompsInWorkgroup()
Dim ComputerInfo As Computer_info_101
Dim i, MaxLenPref, level, ret, EntriesRead, TotalEntries, ResumeHandle As Integer
Dim BufPtr As Integer
Dim iPtr As IntPtr
MaxLenPref = -1
level = 101
ret = NetServerEnum(0, level, BufPtr, MaxLenPref, EntriesRead, TotalEntries, _
SV_TYPE_SERVER, "MSHOME", ResumeHandle) ' Enter your workgroup name here
If ret <> 0 Then
Console.WriteLine("An Error has occured")
Return
End If
' loop thru the entries
For i = 0 To EntriesRead - 1
' copy the stuff into our structure
Dim ptr As IntPtr = New IntPtr(BufPtr)
ComputerInfo = CType(Marshal.PtrToStructure(ptr, GetType(Computer_info_101)), _
Computer_info_101)
BufPtr = BufPtr + Len(ComputerInfo)
lv.Items.Add(ComputerInfo.Name)
Next
NetApiBufferFree(BufPtr)
End Sub
Private Sub b_click(ByVal sender As Object, ByVal e As System.EventArgs)
ListCompsInWorkgroup()
End Sub
Nov 17th, 2005, 11:17 AM
#27
Re: [ask] detect all computer in network
I posted the source code in the class attachment. Just use it like so.
VB Code:
'Adds to a listview control:
Dim Servers As New clsNetwork
Dim compNames As New ArrayList
Dim compName As String
Dim x As Integer
compNames = Servers.GetServers(vbNullString, Servers.SV_TYPE_ALL).Clone()
For x = 0 To compNames.Count - 1
lvwNetwork.Items.Add(compNames.Item(x).ToString)
Next
compNames.Clear()
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Nov 17th, 2005, 09:39 PM
#28
Thread Starter
Member
Re: [ask] detect all computer in network
thanks to all,
and i've tried rob's program(it worked), and jools too, thanks to u all, now i must learn the source code.
Nov 17th, 2005, 09:43 PM
#29
Thread Starter
Member
Re: [ask] detect all computer in network
o , and what about the IP number of each computer, and in jools code, we must enter workgroup's name by ourself, but how to make the program automatically search comps name and ip only in its workgroup, thanks
Last edited by paul_heru; Nov 17th, 2005 at 09:49 PM .
May 3rd, 2009, 08:34 PM
#30
New Member
Re: [ask] detect all computer in network
Heya, could you please give your version in VB6 Rob?
May 7th, 2009, 05:17 AM
#31
Member
Re: [ask] detect all computer in network
Can anyone let me know where ROb's class attachment exists so that I can try it out? I am in dire need of that? where can I find clsNetwork?
Last edited by saechira; May 7th, 2009 at 06:54 AM .
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width