Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

nethood names in a listbox

Posted on 2002-03-15
4
Medium Priority
?
155 Views
Last Modified: 2011-09-20
Hi,
i am developing a project in VB, whereby i want all the computer names(of the LAN)  which are ON in a list box. these names can be seen in the network neighborhood folder but i want these names in a list box.
i would also like to find  the users on these computers which will be listed in a separate list box.
i tried using the BrowseForFolder() function but did not succeed.
0
Comment
Question by:RanjiniPraba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 120 total points
ID: 6867566
Check out this API:

Const ERROR_SUCCESS = 0
Const ERROR_MORE_DATA = 234
Const SV_TYPE_SERVER = &H0   'Server type mask, all types of servers

Const SIZE_SI_101 = 24

Private Type SERVER_INFO_101
 dwPlatformId As Long
 lpszServerName As Long
 dwVersionMajor As Long
 dwVersionMinor As Long
 dwType As Long
 lpszComment As Long
End Type
 
Private Declare Function NetServerEnum Lib "netapi32.dll" ( _
     ByVal servername As String, _
     ByVal level As Long, _
     buffer As Long, _
     ByVal prefmaxlen As Long, _
     entriesread As Long, _
     totalentries As Long, _
     ByVal ServerType As Long, _
     ByVal Domain As String, _
     resumehandle As Long) As Long

Private Declare Function NetApiBufferFree Lib "netapi32.dll" ( _
  BufPtr As Any) As Long
 
Private Declare Sub RtlMoveMemory Lib "KERNEL32" ( _
  hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
 
Private Declare Function lstrcpyW Lib "KERNEL32" ( _
  ByVal lpszDest As String, ByVal lpszSrc As Long) As Long

Private Function PointerToString(lpszString As Long) As String
  Dim lpszStr1 As String, lpszStr2 As String, nRes As Long
  lpszStr1 = String(1000, "*")
  nRes = lstrcpyW(lpszStr1, lpszString)
  lpszStr2 = (StrConv(lpszStr1, vbFromUnicode))
  PointerToString = Left(lpszStr2, InStr(lpszStr2, Chr$(0)) - 1)
End Function




Public Sub SearchOnDomain(Optional Domain As String = vbNullString)
 Dim vntData As SERVER_INFO_101
 Dim lngRead As Long
 Dim lngTotal As Long
 Dim strDomain As String
 Dim strServer As String
 Dim lngLevel As Long
 Dim lngMaxLen As Long
 Dim lngResume As Long
 Dim BufPtr As Long
 
 Dim tmpPtr As Long
 Dim i As Long
 
 strServer = vbNullString
 If Domain = vbNullString Or Domain = "" Then
   strDomain = vbNullString
 Else
   strDomain = StrConv(Domain, vbUnicode)
 End If
 
 lngLevel = 101
 lngMaxLen = -1
 lngRead = 0
 lngTotal = 0
 lngResume = 0
 
 Call NetServerEnum(strServer, lngLevel, BufPtr, lngMaxLen, _
   lngRead, lngTotal, SV_TYPE_SERVER, strDomain, lngResume)
 
 tmpPtr = BufPtr
 For i = 1 To lngRead
   RtlMoveMemory vntData, tmpPtr, SIZE_SI_101
   strServer = PointerToString(vntData.lpszServerName)
   tmpPtr = tmpPtr + SIZE_SI_101
   
   debug.Print strServer
 Next i

End Sub


CHeers
0
 

Author Comment

by:RanjiniPraba
ID: 6879425
hi
i get the following error message on running the code

Runtime error "453"
cant find DLL entry point NetServerEnum in netapi32.dll

I cant find this function in win32api either
please help
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6879460
Depending on the OS:

Private Declare Function NetServerEnum Alias "NetServerEnumA" Lib "netapi32.dll"

or

Private Declare Function NetServerEnum Alias "NetServerEnumB" Lib "netapi32.dll"

The same applies of course to
NetApiBufferFree

Cheers
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6879462
sorry for a typo:

or

Private Declare Function NetServerEnum Alias "NetServerEnumW" Lib "netapi32.dll"

CHeers
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question