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
Printable View
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
You could probably do this by pinging the ips on the LAN
NET USER will give you the username of everyone that's connected at the time.
How do I use the NET USER function then because I cannot find it on the internet or Object Explorer.
start>run>cmd>net user
:) Is there anyway to put them into a listview control. So it would be like network neighborhood. :)
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.
:DVB 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!
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
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
rob dogs code must be put into a module, and called from your form, it wont work in the form :)
just came accross this, hope it will help you :)
http://www.developerfusion.com/show/3169/
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.