?
Solved

identify Windows NT/98 user

Posted on 2002-07-16
4
Medium Priority
?
138 Views
Last Modified: 2010-05-02
Hi

thru Vb i want to identify the user currently logged into Windows NT/98/2000 session. plz suggest how to do it.

thanks
0
Comment
Question by:navneetha
  • 2
4 Comments
 
LVL 14

Expert Comment

by:ajexpert
ID: 7158770
This snippet will diplay name of currently logged on user

' API
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
  "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Command1_Click ()
  Dim RetVal As Long
  Dim Puffer As String * 256
  Dim UserName As String
 
  RetVal = GetUserName(Puffer, Len(Puffer))

  ' Bei vbNullChar "abtrennen" und anzeigen
  If RetVal <> 0 Then
      UserName = Left$(Puffer, Instr(1, Puffer, vbNullChar) - 1)    
    MsgBox "Hallo " & UserName
  End If
End Sub
0
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 150 total points
ID: 7158771
Try GetUserName API or use Environ("USERNAME") ?
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 7158796
Any reason why 'B' is given, navneetha?
0
 

Author Comment

by:navneetha
ID: 7158849
No dear. the answer though i did not know seem to be very simple.

but nothing in particular. was vey useful !!!!

anyway where r u from ??
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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

850 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