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

x
?
Solved

How get the user's login name?

Posted on 2002-06-15
2
Medium Priority
?
130 Views
Last Modified: 2010-05-02
Basics:  VB6 sp5.  Running on Windows NT or Windows 2000.

How do I read the user's login name on a W/NT or W/2000 system?  I assume the user's login name is stored in a system memory variable that I can access.

Thanks.
0
Comment
Question by:EYoung
2 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 100 total points
ID: 7080845
MsgBox environ("username")
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7080986
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Form_Load()
    Dim strUserName As String

    'Create a buffer
    strUserName = String(100, Chr$(0))
    'Get the username
    GetUserName strUserName, 100
    'strip the rest of the buffer
    strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)

    'Show the temppath and the username
    MsgBox "Hello " & strUserName
End Sub


hongjun
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

927 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