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!
Printable View
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!
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
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"
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
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 :)
it didn't work in w98.
something about the netapi32.dll...
im gonna see what i can find...