Find Current Username - Vb

username

Snippet Code


  
Rate this page :
  [ 0 votes]

To find windows username.Just place in the code view and start form. Username will appear.

Option Explicit Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Sub Form_Activate() Dim Result As Long Dim Username As String Dim LenUserName As Long Cls LenUserName = 256 Username = Space(LenUserName) Result = GetUserName(Username, LenUserName) If Result <> 0 Then Print Left$(Username, LenUserName) Else Print "Error" End If End Sub

Tags


Ask Questions

Ask Question