Solved

User

Posted on 1998-10-12
3
133 Views
Last Modified: 2010-04-30
How do I get the Current NT LoginName?
0
Comment
Question by:TheAnswerMan
3 Comments
 
LVL 3

Accepted Solution

by:
vmano earned 10 total points
ID: 1439425
Type the following code into a new module:
 
     ' Makes sure all variables are dimensioned in each subroutine.
     Option Explicit
 
     ' Access the GetUserNameA function in advapi32.dll and
     ' call the function GetUserName.
     Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
     (ByVal lpBuffer As String, nSize As Long) As Long
 
     ' Main routine to Dimension variables, retrieve user name
     ' and display answer.
     Sub Get_User_Name()
 
     ' Dimension variables
     Dim lpBuff As String * 25
     Dim ret As Long, UserName As String
 
     ' Get the user name minus any trailing spaces found in the name.
     ret = GetUserName(lpBuff, 25)
     UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
 
     ' Display the User Name
     MsgBox UserName
     End Sub

0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 1439426
thanks
0
 
LVL 1

Expert Comment

by:tommy_boy
ID: 1439427
what about Environ("User")?
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now