Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can someone please tel me how I can get the username from the one that is logged into my windows 2000 system?
I want to do this with Visual Basic 6.0.
Is there some kind of API call to do this?

i think this is the code your looking for
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Public OK As Boolean
Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
If lSize > 0 Then
txtUserName.Text = Left$(sBuffer, lSize)
Else
txtUserName.Text = vbNullString
End If
End Subcopied straight from the application wizard in vb 6 on w2k machine.
run the application wizard and use logon screen ect and the code is put in for you, then you know how it works

![]() |
DMA programming
|
how store ping result
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |