Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Retrieve Networsk users and PC User

Posted on 1999-07-15
Medium Priority
Last Modified: 2010-05-02
With VB5, i need to retrieve all usernames of all workgroups of a intranet, and the local PC username too.
How can i do this?
(i think this q, is easy, say me if i need encrease pts).
Question by:fab1970
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
LVL 13

Expert Comment

ID: 1524922

Expert Comment

ID: 1524923
try using the api WNetGetConnection. This should be able to help you.

Author Comment

ID: 1524924
I'm not very skilled about API.
Can you write a little bit of code?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 10

Accepted Solution

viktornet earned 100 total points
ID: 1524925
WNetGetConnection() is used to get the network mappings and GetUserName() is used to get the PC User's name.... here are some codes...

GetUserName() would be easy for you to use so I won't get into that, but if you need some code for that too please lemme know...

and here is some code got WNetGetConnection()

function GetNetworkDriveMappings(sl as ListBox ) as integer
  dim  i as integer
  dim sNetPath as string
  dim dwMaxNetPathLen as long

  dwMaxNetPathLen = MAX_PATH 'MAX_PATH = 260
  sNetPath = $space(dwMaxNetPathLen)
  for i = 0 to 25
    if WNetGetConnection(Chr(65+i)&":", sNetPath, dwMaxNetPathLen )=NO_ERROR then sl.AddItem(Chr(65+i)&": "&sNetPath)
  next i
  GetNetworkDriveMappings = sl.ListCount
end function

Hope this helps...

btw, don't gorget to declare the WNetGetConnection() function in a separate module before you use it... r you can declare it in the form module but you'd have to declare it as a private function...

if you need the function declaration please let me know...

LVL 10

Expert Comment

ID: 1524926

sNetPath = $space(dwMaxNetPathLen)

should read...

sNetPath = Space$(dwMaxNetPathLen)

sorry :))
LVL 10

Expert Comment

ID: 1524927
oh and another thing... NO_ERROR is a constant and is equal to 0 ;-))

and you can use the function like so...

Private Sub Command1_Click()
    Caption = GetNetworkDriveMappings(List1) & " Items Collected"
End Sub

Good Luck!!


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

660 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