thnks to jim mcnamara i found the code bellow that does what i am asking but if u try it at win9x u will get the error that netapi32.dll not found


To a form, add a listbox (List1) and five text boxes (Text1 through Text5). Add the following code:
VB Code:
  1. Option Explicit
  2. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  3. ' Copyright ©1996-2002 VBnet, Randy Birch, All Rights Reserved.
  4. ' Some pages may also contain other copyrights by the author.
  5. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  6. ' Distribution: You can freely use this code in your own
  7. '               applications, but you can not publish
  8. '               or reproduce this code on any web site,
  9. '               on any online service, or distribute on
  10. '               any media without express permission.
  11. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  12. 'Windows type used to call the Net API
  13. Private Type USER_INFO_10
  14.    usr10_name          As Long
  15.    usr10_comment       As Long
  16.    usr10_usr_comment   As Long
  17.    usr10_full_name     As Long
  18. End Type
  19.  
  20. 'private type to hold the actual strings displayed
  21. Private Type USER_INFO
  22.    name          As String
  23.    full_name     As String
  24.    comment       As String
  25.    usr_comment   As String
  26. End Type
  27.  
  28. Private Const ERROR_SUCCESS As Long = 0&
  29. Private Const MAX_COMPUTERNAME As Long = 15
  30. Private Const MAX_USERNAME As Long = 256
  31. Private Const FILTER_NORMAL_ACCOUNT  As Long = &H2
  32.  
  33. Private Declare Function NetUserGetInfo Lib "netapi32" _
  34.    (lpServer As Byte, _
  35.    username As Byte, _
  36.    ByVal level As Long, _
  37.    lpBuffer As Long) As Long
  38.    
  39. Private Declare Function NetUserEnum Lib "netapi32" _
  40.   (servername As Byte, _
  41.    ByVal level As Long, _
  42.    ByVal filter As Long, _
  43.    buff As Long, _
  44.    ByVal buffsize As Long, _
  45.    entriesread As Long, _
  46.    totalentries As Long, _
  47.    resumehandle As Long) As Long
  48.    
  49. Private Declare Function NetApiBufferFree Lib "netapi32" _
  50.   (ByVal Buffer As Long) As Long
  51.  
  52. Private Declare Function GetUserName Lib "advapi32" _
  53.    Alias "GetUserNameA" _
  54.   (ByVal lpBuffer As String, _
  55.    nSize As Long) As Long
  56.    
  57. Private Declare Function GetComputerName Lib "kernel32" _
  58.    Alias "GetComputerNameA" _
  59.   (ByVal lpBuffer As String, _
  60.    nSize As Long) As Long
  61.  
  62. Private Declare Sub CopyMemory Lib "kernel32" _
  63.    Alias "RtlMoveMemory" _
  64.   (xDest As Any, _
  65.    xSource As Any, _
  66.    ByVal nBytes As Long)
  67.  
  68. Private Declare Function lstrlenW Lib "kernel32" _
  69.   (ByVal lpString As Long) As Long
  70.  
  71. Private Declare Function StrLen Lib "kernel32" _
  72.    Alias "lstrlenW" _
  73.   (ByVal lpString As Long) As Long
  74.  
  75.  
  76. Private Sub Form_Load()
  77.  
  78.    Dim tmp As String
  79.    Dim bServername() As Byte
  80.    
  81.    tmp = rgbGetComputerName()
  82.  
  83.   'assure the server string is properly formatted
  84.    If Len(tmp) Then
  85.    
  86.       If InStr(tmp, "\\") Then
  87.             bServername = tmp & Chr$(0)
  88.       Else: bServername = "\\" & tmp & Chr$(0)
  89.       End If
  90.    
  91.    End If
  92.    
  93.    Text1.Text = tmp
  94.  
  95.    Call GetUserEnumInfo(bServername())
  96.    
  97. End Sub
  98.  
  99.  
  100. Private Function GetUserEnumInfo(bServername() As Byte)
  101.  
  102.    Dim users() As Long
  103.    Dim buff As Long
  104.    Dim buffsize As Long
  105.    Dim entriesread As Long
  106.    Dim totalentries As Long
  107.    Dim cnt As Integer
  108.    
  109.    buffsize = 255
  110.    
  111.    If NetUserEnum(bServername(0), 0, _
  112.                    FILTER_NORMAL_ACCOUNT, _
  113.                    buff, buffsize, _
  114.                    entriesread, _
  115.                    totalentries, 0&) = ERROR_SUCCESS Then
  116.    
  117.       ReDim users(0 To entriesread - 1) As Long
  118.       CopyMemory users(0), ByVal buff, entriesread * 4
  119.      
  120.       For cnt = 0 To entriesread - 1
  121.          List1.AddItem GetPointerToByteStringW(users(cnt))
  122.       Next cnt
  123.      
  124.       NetApiBufferFree buff
  125.    
  126.    End If
  127.  
  128. End Function
  129.  
  130.  
  131. Private Function rgbGetComputerName() As String
  132.  
  133.   'returns the name of the computer
  134.    Dim tmp As String
  135.    
  136.    tmp = Space$(MAX_COMPUTERNAME + 1)
  137.    
  138.    If GetComputerName(tmp, Len(tmp)) <> 0 Then
  139.       rgbGetComputerName = TrimNull(tmp)
  140.    End If
  141.    
  142. End Function
  143.  
  144.  
  145. Private Function TrimNull(item As String)
  146.  
  147.    Dim pos As Integer
  148.    
  149.    pos = InStr(item, Chr$(0))
  150.    
  151.    If pos Then
  152.          TrimNull = Left$(item, pos - 1)
  153.    Else: TrimNull = item
  154.    End If
  155.    
  156. End Function
  157.  
  158.  
  159. Private Function GetUserNetworkInfo(bServername() As Byte, bUsername() As Byte) As USER_INFO
  160.    
  161.    Dim usrapi As USER_INFO_10
  162.    Dim buff As Long
  163.    
  164.    If NetUserGetInfo(bServername(0), bUsername(0), 10, buff) = ERROR_SUCCESS Then
  165.      
  166.      'copy the data from buff into the
  167.      'API user_10 structure
  168.       CopyMemory usrapi, ByVal buff, Len(usrapi)
  169.      
  170.      'extract each member and return
  171.      'as members of the UDT
  172.       GetUserNetworkInfo.name = GetPointerToByteStringW(usrapi.usr10_name)
  173.       GetUserNetworkInfo.full_name = GetPointerToByteStringW(usrapi.usr10_full_name)
  174.       GetUserNetworkInfo.comment = GetPointerToByteStringW(usrapi.usr10_comment)
  175.       GetUserNetworkInfo.usr_comment = GetPointerToByteStringW(usrapi.usr10_usr_comment)
  176.    
  177.       NetApiBufferFree buff
  178.    
  179.    End If
  180.    
  181. End Function
  182.  
  183.  
  184. Private Function GetPointerToByteStringW(lpString As Long) As String
  185.  
  186.    Dim buff() As Byte
  187.    Dim nSize As Long
  188.    
  189.    If lpString Then
  190.    
  191.      'its Unicode, so mult. by 2
  192.       nSize = lstrlenW(lpString) * 2
  193.      
  194.       If nSize Then
  195.          ReDim buff(0 To (nSize - 1)) As Byte
  196.          CopyMemory buff(0), ByVal lpString, nSize
  197.          GetPointerToByteStringW = buff
  198.      End If
  199.      
  200.    End If
  201.    
  202. End Function
  203.  
  204.  
  205. Private Sub List1_Click()
  206.  
  207.    Dim usr As USER_INFO
  208.    Dim bUsername() As Byte
  209.    Dim bServername() As Byte
  210.    Dim tmp As String
  211.  
  212.   'This assures that both the server
  213.   'and user params have data
  214.    If Len(Text1.Text) And List1.ListIndex > -1 Then
  215.    
  216.       bUsername = List1.List(List1.ListIndex) & Chr$(0)
  217.    
  218.      'This demo uses the current machine as the
  219.      'server param, which works on NT4 and Win2000.
  220.      'If connected to a PDC or BDC, pass that
  221.      'name as the server, instead of the return
  222.      'value from GetComputerName().
  223.       tmp = Text1.Text
  224.    
  225.      'assure the server string is properly formatted
  226.       If Len(tmp) Then
  227.      
  228.          If InStr(tmp, "\\") Then
  229.                bServername = tmp & Chr$(0)
  230.          Else: bServername = "\\" & tmp & Chr$(0)
  231.          End If
  232.      
  233.       End If
  234.    
  235.      'Return the user information for the passed
  236.      'user. The return values are assigned directly
  237.      'to the non-API USER_INFO data type that we
  238.      'defined (I prefer UDTs). Alternatively, if
  239.      'you're a 'classy' sort of guy,  the return
  240.      'values could be assigned directly to properties
  241.      'in the function.
  242.       usr = GetUserNetworkInfo(bServername(), bUsername())
  243.      
  244.       Text3.Text = usr.name
  245.      
  246.      'The call may or may not return the
  247.      'full name, comment or usr_comment
  248.      'members, depending on the user's
  249.      'listing in User Manager.
  250.       Text4.Text = usr.full_name
  251.       Text5.Text = usr.comment
  252.       Text6.Text = usr.usr_comment
  253.    
  254.    End If
  255.  
  256. End Sub
  257. '--end block--

can ne1 help how to overcome this problem?

thnks