Get the name of the current user, and the computer
VB Code:
Option Explicit Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, _ nSize As Long) _ As Long Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, _ nSize As Long) _ As Long Private Function ReturnUserName() As String ReturnUserName = Space$(255) Call GetUserName(ReturnUserName, Len(ReturnUserName)) End Function Private Function ReturnComputerName() As String ReturnComputerName = Space$(255) Call GetComputerName(ReturnComputerName, Len(ReturnComputerName)) End Function Private Sub Command1_Click() MsgBox ReturnUserName MsgBox ReturnComputerName End Sub
![]()




Reply With Quote