Need to edge out the competition for your dream job? Train for certifications today.
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function WhoAmI(bReturnUserName As Boolean) As String
' Function returns either user name or computer name
Dim strName As String * 255
10 If bReturnUserName = True Then
20 GetUserNameA strName, Len(strName)
40 GetComputerNameA strName, Len(strName)
50 End If
60 WhoAmI = left$(strName, InStr(strName, vbNullChar) - 1)
Open in new window
This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.
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.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.