I'm working in a NT domain, from a PC running Windows 9x. How can I know the user currently logged in?
Thanks in advance
Printable View
I'm working in a NT domain, from a PC running Windows 9x. How can I know the user currently logged in?
Thanks in advance
Here you go:
Code:Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim strBuffer As String
strBuffer = Space(125)
If GetUserName(strBuffer, Len(strBuffer)) Then
MsgBox Left(strBuffer, InStr(strBuffer, vbNullChar) - 1)
End If
End Sub