?
Solved

User

Posted on 1998-10-12
3
Medium Priority
?
139 Views
Last Modified: 2010-04-30
How do I get the Current NT LoginName?
0
Comment
Question by:TheAnswerMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
vmano earned 40 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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
Course of the Month15 days, 17 hours left to enroll

741 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