I'm using the following code to get the login name from an NT workstation.
I do get the results back ok but, when it brings back the information it
also appends an unknown character, based on length variable passed, to the
end of the login name. Does anyone know how I can strip off this unknown
character? Since login names vary it can't be a fixed value that is why in
this example I pass 40 to GetNtUser.
Thanks,
'need this .dll to read system registry
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
_
(ByVal lpBuffer As String, nSize As Long) As Long
Public hostName As String
Public IPAddress As String
Public loginName As String
Public Sub Main()
'get local system information
hostName = frmIP.Winsock.LocalHostName
IPAddress = frmIP.Winsock.LocalIP
loginName = GetNtUser
End Sub
Public Function GetNtUser() As String
Dim longVal As Long
Dim strVal As String * 40
longVal = GetUserName(strVal, 40)
GetNtUser = strVal
End Function