Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting User Login under Windows NT

Posted on 2000-03-06
3
Medium Priority
?
176 Views
Last Modified: 2010-05-02
I'm programming a multiuser application under Windows NT.
My program should be able to identify a user by his NT-Login name.
I know that there is a DLL-Method which returns the userID of the current user. But I don't know which DLL does this.

Perhaps someone can help me.
0
Comment
Question by:rainerHOLZ
3 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2588131
Use this:

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

Private Sub Form_Load()
    Dim sBuffer As String
    Dim lSize As Long


    sBuffer = Space$(255)
    lSize = Len(sBuffer)
    Call GetUserName(sBuffer, lSize)
    If lSize > 0 Then
        txtUserName.Text = Left$(sBuffer, lSize)
    Else
        txtUserName.Text = vbNullString
    End If
End Sub
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 400 total points
ID: 2588134
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
    Dim strUser As String * 25
    GetUserName strUser, 25
    MsgBox strUser
End Sub

This will get the user name of the currently logged in user.
0
 

Author Comment

by:rainerHOLZ
ID: 2595048
Thak you!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

926 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