Results 1 to 31 of 31

Thread: [ask] detect all computer in network

  1. #1

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    Thumbs up [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

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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?

  3. #3

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    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

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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

  5. #5

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    Re: [ask] detect all computer in network

    well, thanks for the effort to help me, i'll try to look at it then

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [ask] detect all computer in network

    Perhaps you could also utilize the output of Net View or use WMI...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    Re: [ask] detect all computer in network

    Quote 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 ?

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  9. #9
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [ask] detect all computer in network

    Quote 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!
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [ask] detect all computer in network

    I think its something like this?

    VB Code:
    1. <MarshalAs(UnmanagedType.LPStr)> _
    2. Private Const LMCSTR As Int32 = LPCSTR
    3. <MarshalAs(UnmanagedType.LPStr)> _
    4. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  14. #14

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    Re: [ask] detect all computer in network

    ????
    sorry but im really2 confused
    Last edited by paul_heru; Nov 16th, 2005 at 10:35 PM.

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  16. #16
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: [ask] detect all computer in network

    Gotta love those API call conversions... (remember.. byval or byref )

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [ask] detect all computer in network

    Hey gig! Mind if I throw some APIs at you?
    VB Code:
    1. <StructLayout(LayoutKind.Sequential)> _
    2.     Public Structure SERVER_INFO_100
    3.         <MarshalAs(UnmanagedType.LPStr)> _
    4.         Friend sv100_platform_id As Integer
    5.         <MarshalAs(UnmanagedType.LPStr)> _
    6.         Friend sv100_name As Integer
    7.     End Structure
    8.  
    9.     Private Declare Auto Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pTo As Integer, ByRef uFrom As Integer, ByVal lSize As Integer)
    10.     Private Declare Auto Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pTo As String, ByRef uFrom As Integer, ByVal lSize As Integer)
    11.  
    12. Private Sub Button1_Click(blah, blah, blah....
    13.     Dim se100 As SERVER_INFO_100
    14.     Dim bufptr As Integer
    15.     Dim nStructSize As Integer
    16.     Dim Cnt As Integer
    17.  
    18.     '...
    19.  
    20.     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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  18. #18
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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..

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  20. #20
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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.

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [ask] detect all computer in network

    Looks like they dont even use CopyMemory. The use a DirectCast -
    VB Code:
    1. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  24. #24

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    Re: [ask] detect all computer in network

    Quote Originally Posted by RobDog888
    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.
    thanks rob , but how to use it?, ill be waiting for your source code of the program

  25. #25
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [ask] detect all computer in network

    How about this?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  26. #26
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    297

    Re: [ask] detect all computer in network

    for the without domain bit:
    from google groups
    VB Code:
    1. '
    2.     'Imports system.runtime.interopservices
    3.     Dim WithEvents b As New Button
    4.     Dim lv As New ListView
    5.  
    6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7.         b.Location = New Point((Me.ClientSize.Width - b.Width) \ 2, Me.ClientSize.Height - 60)
    8.         b.Text = "list"
    9.         lv.View = View.Details
    10.         lv.Columns.Add("Workgroup Computers", 300, HorizontalAlignment.Left)
    11.         lv.Dock = DockStyle.Top
    12.         lv.Height = Me.ClientSize.Height - 80
    13.         Me.Controls.Add(lv)
    14.         Me.Controls.Add(b)
    15.         AddHandler b.Click, AddressOf b_click
    16.     End Sub
    17.  
    18.     Declare Unicode Function NetServerEnum Lib "Netapi32.dll" _
    19.     (ByVal Servername As Integer, ByVal level As Integer, _
    20.         ByRef buffer As Integer, ByVal PrefMaxLen As Integer, _
    21.         ByRef EntriesRead As Integer, ByRef TotalEntries As Integer, _
    22.         ByVal ServerType As Integer, ByVal DomainName As String, _
    23.         ByRef ResumeHandle As Integer) As Integer
    24.  
    25.     Declare Function NetApiBufferFree Lib "Netapi32.dll" _
    26.         (ByVal lpBuffer As Integer) As Integer
    27.  
    28.  
    29.     Structure Computer_info_101
    30.         Public Platform_ID As Integer
    31.         <MarshalAsAttribute(UnmanagedType.LPWStr)> Public Name As String
    32.         Public Version_Major As Integer
    33.         Public Version_Minor As Integer
    34.         Public Type As Integer
    35.         <MarshalAsAttribute(UnmanagedType.LPWStr)> Public Comment As String
    36.     End Structure
    37.  
    38.     Private Const SV_TYPE_SERVER As Integer = &H2 ' All Servers
    39.  
    40.     Private Sub ListCompsInWorkgroup()
    41.  
    42.         Dim ComputerInfo As Computer_info_101
    43.         Dim i, MaxLenPref, level, ret, EntriesRead, TotalEntries, ResumeHandle As Integer
    44.         Dim BufPtr As Integer
    45.         Dim iPtr As IntPtr
    46.         MaxLenPref = -1
    47.         level = 101
    48.         ret = NetServerEnum(0, level, BufPtr, MaxLenPref, EntriesRead, TotalEntries, _
    49.         SV_TYPE_SERVER, "MSHOME", ResumeHandle) ' Enter your workgroup name here
    50.         If ret <> 0 Then
    51.             Console.WriteLine("An Error has occured")
    52.             Return
    53.         End If
    54.         ' loop thru the entries
    55.         For i = 0 To EntriesRead - 1
    56.             ' copy the stuff into our structure
    57.             Dim ptr As IntPtr = New IntPtr(BufPtr)
    58.             ComputerInfo = CType(Marshal.PtrToStructure(ptr, GetType(Computer_info_101)), _
    59.             Computer_info_101)
    60.             BufPtr = BufPtr + Len(ComputerInfo)
    61.             lv.Items.Add(ComputerInfo.Name)
    62.         Next
    63.         NetApiBufferFree(BufPtr)
    64.  
    65.     End Sub
    66.  
    67.     Private Sub b_click(ByVal sender As Object, ByVal e As System.EventArgs)
    68.         ListCompsInWorkgroup()
    69.     End Sub

  27. #27
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [ask] detect all computer in network

    I posted the source code in the class attachment. Just use it like so.
    VB Code:
    1. 'Adds to a listview control:
    2.  
    3.         Dim Servers As New clsNetwork
    4.         Dim compNames As New ArrayList
    5.         Dim compName As String
    6.         Dim x As Integer
    7.  
    8.         compNames = Servers.GetServers(vbNullString, Servers.SV_TYPE_ALL).Clone()
    9.         For x = 0 To compNames.Count - 1
    10.             lvwNetwork.Items.Add(compNames.Item(x).ToString)
    11.         Next
    12.         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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  28. #28

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    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.

  29. #29

    Thread Starter
    Member paul_heru's Avatar
    Join Date
    Nov 2005
    Posts
    32

    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.

  30. #30
    New Member
    Join Date
    May 2009
    Posts
    2

    Re: [ask] detect all computer in network

    Heya, could you please give your version in VB6 Rob?

  31. #31
    Member
    Join Date
    Apr 2008
    Posts
    40

    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
  •  



Click Here to Expand Forum to Full Width