Hi,
If you have an active directory
http://www.vbdotnetheaven.com/Code/May2003/1004.asp
Home network sample console app
Imports System.Runtime. InteropServices
Module Module1
Structure Computer_info_1 01
Public Platform_ID As Integer
<MarshalAsAttri bute(UnmanagedT ype.LPWStr)> Public Name As String
Public Version_Major As Integer
Public Version_Minor As Integer
Public Type As Integer
<MarshalAsAttri bute(UnmanagedT ype.LPWStr)> Public Comment As String
End Structure
Declare Unicode Function NetServerEnum Lib "Netapi32.d ll" _
(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 NetApiBufferFre e Lib "Netapi32.d ll" _
(ByVal lpBuffer As Integer) As Integer
Private Const SV_TYPE_SERVER As Integer = &H2 ' All Servers
Sub Main()
Dim ComputerInfo As Computer_info_1 01
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) ' Replace MSHOME with your workgroup
name
If ret <> 0 Then
Console.WriteLi ne("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.P trToStructure(p tr,
GetType(Compute r_info_101)), _
Computer_info_1 01)
BufPtr = BufPtr + Len(ComputerInf o)
Console.WriteLi ne(computerInfo .Name)
Next
NetApiBufferFre e(BufPtr)
Console.Write(" Press Enter to End")
Dim s As String = Console.ReadLin e()
End Sub
End Module
Ken
---------------------------
"Robert Fitzpatrick" <rf************ @online.yahoo.c om> wrote in message
news:11******** *************** *****@phx.gbl.. .
Hello,
I'm looking for code examples that displays all the
machines in a domain/workgroup using VB.NET. I've seen
a few postings on the net on how to do this in VB6, but
these will not work for us.
Thanks
RF