Results 1 to 3 of 3

Thread: Help!!! How do i know the Current User??

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    Olympia,Wa,USA
    Posts
    7
    How can i get the name of the current user logged in windows?? Please reply if you know...
    Thanks in advance..

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can use GetUserName API.
    Code:
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    
    Private Sub Command1_Click()
        Dim lngRet As Long
        Dim strUser As String
        
        strUser = Space(125)
        lngRet = GetUserName(strUser, Len(strUser))
        If lngRet Then
            MsgBox "UserName: " & strUser
        End If
    End Sub

  3. #3
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    MUCH EASIER WAY TO DO THIS!!

    Text1.Text = "Username: " & Environ$("USERNAME")

    that's it. good luck.

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width