Results 1 to 6 of 6

Thread: Getting the full name of the current user help!!!

  1. #1
    ruyeno22
    Guest

    Question Getting the full name of the current user help!!!

    Hi:

    I want to know if anyone can help with this problem:

    i want to retrieve the current user's FULL NAME

    for example jdoe would be "John Doe". i want to retrieve "John Doe".

    is the answer windows NT4.0 / 2000 independent????

    thanks people!

  2. #2
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    I know this works with 95/98. You'd have to test for NT/2000.

    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
    (ByVal lpBuffer As String, nSize As Long) As Long

    Function UserName() As String
    Dim buffer As String * 512, length As Long
    length = Len(buffer)
    If GetUserName(buffer, length) Then
    ' returns non-zero if successful, and modifies the length argument
    UserName = Left$(buffer, length - 1)
    End If
    End Function

    Usage:

    dim s as string

    s = UserName()
    MsgBox s

    John

  3. #3
    ruyeno22
    Guest

    Question yes, but...

    as far as i know, with that function you get the user id:

    for example: jdoe

    i waant to get the full name of the user, for example, when you create jdoe, you enter the full name "Jonh Doe". you jdoe and "jonh doe"

    i want to retrieve "John Doe"

  4. #4
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    http://www.mvps.org/vbnet/index.html...sergetinfo.htm

    The above link will give you just what you want, if you use NT or 2000. User name, Computer Name, Full User Name and Comments if there are any.

    Since Windows 95/98 are never officially added to a Domain, I don't see how you could get User Name for those OS.

    Great site to spend time at if your into VB.

    HTH
    John

  5. #5
    ruyeno22
    Guest

    Thanks man!

    we are trying to get the full name so the program can "generate" the email of the person (1st letter of the first name + the last name, for example: John Doe's email: jdoe@whatever) .

    we really don't have the time to see how to access the active directory ...

    it's working in one computer with windows 2000, we are going to check with a w98 PC.

    thanks man!!!! I O U 1

  6. #6
    ruyeno22
    Guest

    you were right...

    it didn't work in w98.

    something about the netapi32.dll...

    im gonna see what i can find...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width