50 pts...Registry

I think I have figured out how to retrieve data from program areas of the registry, but could someone please tell me how to get the NT username from the registry?  I need to use it for a login I am doing.  This is in VB5 if that makes a difference.  Thanks!
Who is Participating?
caraf_gConnect With a Mentor Commented:
You don't get that information from the Registry.

Try this API call.

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long

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
        msgbox Left$(sBuffer, lSize)
        msgbox "Not found"
    End If
End Sub

With thanks to emoreau.

neymeyerAuthor Commented:
Thanks a bunch!  That is good to know.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.