Computing.Net > Forums > Programming > Get username from WIN2k with VB6.0

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Get username from WIN2k with VB6.0

Reply to Message Icon

Name: Carl
Date: April 11, 2002 at 00:20:01 Pacific
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: Mark
Date: April 11, 2002 at 02:18:29 Pacific
Reply:

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 Sub

copied 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


0

Response Number 2
Name: Carl
Date: April 11, 2002 at 03:49:58 Pacific
Reply:

Thanx you very much Mark, works great.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


DMA programming how store ping result



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Get username from WIN2k with VB6.0

vb 6.0 sending emails with formated www.computing.net/answers/programming/vb-60-sending-emails-with-formated/3219.html

Port detecting with VB6 www.computing.net/answers/programming/port-detecting-with-vb6/8580.html

connect VB6.0 with SQL 7.0 www.computing.net/answers/programming/connect-vb60-with-sql-70/5691.html