sgs1970
asked on
Getting windows login name
Hi,
For getting the windows login user name as a string , what is to be done ?
I actually used GetEnvironmentVariable, but the value coming when compared to a string variable is not matching
Thanks,
Sam
For getting the windows login user name as a string , what is to be done ?
I actually used GetEnvironmentVariable, but the value coming when compared to a string variable is not matching
Thanks,
Sam
ASKER
Hi,
See the subroutine I used
Function GetUserName() As String
Dim strUserName As String * 255
strUserName = ""
'Create a string buffer of 255 chars in length
Dim X As Integer
X = GetEnvironmentVariable("US
If X > 0 Then 'Look for Null Character, usually included
X = InStr(strUserName, vbNullChar)
'Trim off buffered spaces too
If X > 0 Then
Else
'' MsgBox (Left$(strUserName, x))
End If
End If
GetUserName = strUserName
End Function
ASKER
The username is not read as a proper string , it seems
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you explain that.