Results 1 to 2 of 2

Thread: Retrieving current user in 98 and NT.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    Atlanta
    Posts
    104
    How, on a multi user machine running windows 98, can I retrieve the current users information?

    All I'm trying to do is get the login name of the user that's currently logged in.

    I looked around about the registry, but I didn't find any documentation about it there (just about the registered user and registered organization).

    Is that information in the registry, and if so, is it the same on 98, 2000 and NT?

    Thanks.

    Jeremy

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Not a problem:
    Code:
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    
    
    Private Sub Command1_Click()
        Dim strUser As String
        Dim lngRet As Long
        
        strUser = Space(125)
        lngRet = GetUserName(strUser, Len(strUser))
        If lngRet Then
            strUser = Left(strUser, InStr(strUser, vbNullChar) - 1)
        End If
        
        MsgBox "Currently logged on as: " & strUser
    End Sub

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