Solved

identify Windows NT/98 user

Posted on 2002-07-16
4
124 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 49

Accepted Solution

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…

708 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

13 Experts available now in Live!

Get 1:1 Help Now