|
-
Aug 6th, 2001, 04:33 PM
#1
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!
-
Aug 6th, 2001, 05:09 PM
#2
Fanatic Member
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
-
Aug 7th, 2001, 04:33 AM
#3
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"
-
Aug 7th, 2001, 07:38 AM
#4
Fanatic Member
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
-
Aug 7th, 2001, 08:03 AM
#5
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
-
Aug 7th, 2001, 08:12 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|