|
-
Sep 17th, 2004, 03:43 PM
#1
Thread Starter
Junior Member
Winsock
Hi,
Is there any possible way to view all the Computers which are turned on , on your LAN as icons so you may select them and use there IP address'.
Thanx
-
Sep 17th, 2004, 05:06 PM
#2
Addicted Member
You could probably do this by pinging the ips on the LAN
-
Sep 17th, 2004, 09:35 PM
#3
NET USER will give you the username of everyone that's connected at the time.
-
Sep 18th, 2004, 08:38 AM
#4
Thread Starter
Junior Member
How do I use the NET USER function then because I cannot find it on the internet or Object Explorer.
-
Sep 18th, 2004, 09:03 AM
#5
Banned
-
Sep 18th, 2004, 10:42 AM
#6
Thread Starter
Junior Member
Is there anyway to put them into a listview control. So it would be like network neighborhood.
-
Sep 18th, 2004, 11:45 AM
#7
This will find all available domains and the computers in each.
It populates a combo (cboDomain) with the domains and when
you click on a domain it will populate another combo
(cboComputer) with the computers in that domain.
VB Code:
'IN A MODULE
Option Explicit
Public Type SERVER_INFO_100
sv100_platform_id As Long
sv100_name As Long
End Type
Public Const SV_TYPE_DOMAIN_ENUM As Long = &H80000000
Public Const SV_TYPE_ALL As Long = &HFFFFFFFF
Public Const MAX_PREFERRED_LENGTH As Long = -1
Public Const NERR_SUCCESS As Long = 0&
Public Const ERROR_REQ_NOT_ACCEP = 71&
Public Const ERROR_MORE_DATA As Long = 234&
Public Const NERR_BASE = 2100
Public Const NERR_InvalidComputer = (NERR_BASE + 251)
Public Declare Function NetServerEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, buf As Any, _
ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, ByVal servertype As Long, ByVal domain As Long, _
resume_handle As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)
Public Declare Function NetApiBufferFree Lib "netapi32" (ByVal Buffer As Long) As Long
Public Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
Public Function GetServers(sDomain As String, sType As Long) As String()
Dim bufptr As Long
Dim dwEntriesread As Long
Dim dwTotalentries As Long
Dim dwResumehandle As Long
Dim se100 As SERVER_INFO_100
Dim success As Long
Dim nStructSize As Long
Dim Cnt As Long
nStructSize = LenB(se100)
success = NetServerEnum(0&, 100, bufptr, MAX_PREFERRED_LENGTH, dwEntriesread, dwTotalentries, sType, StrPtr(sDomain), dwResumehandle)
'success = 71 'NO ACTIVE 'DOMAIN'
If success = NERR_SUCCESS And success <> ERROR_MORE_DATA Then
Dim compNames() As String
ReDim compNames(dwEntriesread)
For Cnt = 0 To dwEntriesread - 1
CopyMemory se100, ByVal bufptr + (nStructSize * Cnt), nStructSize
compNames(Cnt) = GetPointerToByteStringW(se100.sv100_name)
DoEvents
Next
End If
Call NetApiBufferFree(bufptr)
GetServers = compNames
End Function
Public Function GetPointerToByteStringW(ByVal dwData As Long) As String
Dim tmp() As Byte
Dim tmplen As Long
If dwData <> 0 Then
tmplen = lstrlenW(dwData) * 2
If tmplen <> 0 Then
ReDim tmp(0 To (tmplen - 1)) As Byte
CopyMemory tmp(0), ByVal dwData, tmplen
GetPointerToByteStringW = tmp
End If
End If
End Function
'BEHIND A FORM WITH TWO COMBOS (cboDomain AND cboComputer)
Private Sub Form_Load()
Dim compNames() As String
Dim x As Integer
'SETUP THE DOMAIN COMBO BOX
compNames = GetServers(vbNullString, SV_TYPE_DOMAIN_ENUM)
For x = LBound(compNames) To UBound(compNames) - 1
cboDomain.AddItem compNames(x)
Next
cboDomain.ListIndex = 0
End Sub
Private Sub cboDomain_Click()
'NEED TO CLEAR CBOCOMPUTER AND RELOAD WITH COMPUTERS IN THE NEWLY SELECTED DOMAIN
'SETUP THE COMPUTER COMBO BOX
On Error GoTo No_Bugs
Dim compNames() As String
Dim x As Integer
cboComputer.Clear
x = 0
compNames = GetServers(cboDomain.Text, SV_TYPE_ALL)
If UBound(compNames) > 0 Then
For x = LBound(compNames) To UBound(compNames) - 1
cboComputer.AddItem compNames(x)
Next
cboComputer.ListIndex = 0
End If
Exit Sub
No_Bugs:
If Err.Number = "9" Then
cboDomain.RemoveItem (cboDomain.ListIndex)
cboDomain.ListIndex = 0
compNames = GetServers(cboDomain.Text, SV_TYPE_ALL)
Resume
Else
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, App.ProductName
End If
End Sub

VB/Outlook Guru!
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 
-
Sep 18th, 2004, 11:54 AM
#8
This is also good for selecting computers/folders/files,
just in case you may like it instead.
VB Code:
Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Const MAX_PATH = 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtBI As BrowseInfo
With udtBI
'Set the owner window
.hWndOwner = Me.hWnd
'lstrcat appends the two strings and returns the memory address
.lpszTitle = lstrcat("C:\", "")
'Return only if the user selected a directory
.ulFlags = BIF_RETURNONLYFSDIRS
End With
'Show the 'Browse for folder' dialog
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
'Get the path from the IDList
SHGetPathFromIDList lpIDList, sPath
'free the block of memory
CoTaskMemFree lpIDList
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If
MsgBox sPath
End Sub
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 
-
Sep 18th, 2004, 12:06 PM
#9
Thread Starter
Junior Member
RobDog888 could you send me a zip file of your code because I get an error message up everytime I try to run it. Something about Private Const in module or something, anyway it would be greatly appreciated. is it possible to make it appear in a tree view.
Thanx davism
-
Sep 18th, 2004, 12:18 PM
#10
rob dogs code must be put into a module, and called from your form, it wont work in the form
-
Sep 18th, 2004, 04:52 PM
#11
just came accross this, hope it will help you 
http://www.developerfusion.com/show/3169/
-
Sep 26th, 2004, 05:18 AM
#12
Thread Starter
Junior Member
Sorry I haven't replied sooner I've been on hols. I tried all the code you gave me but I get runtime error "48" File not found "Netapi32". So I copied netapi32.dll to the folder of my project and I still get the smae message.
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
|