R
reidarT
How do I get current user logged in with vb.net code?
reidarT
reidarT
Environment.UserName
regards
Michel Posseth [MCP]
reidarT said:Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, ByRef nSize As Integer) As Integer
Public Function GetUserName() As String
Dim iReturn As Integer
Dim userName As String
userName = New String(CChar(" "), 50)
iReturn = GetUserName(userName, 50)
GetUserName = userName.Substring(0, userName.IndexOf(Chr(0)))
End Function
reidarT
Theo Verweij said:Or: My.User.Name
Environment.UserName
regards
Michel Posseth [MCP]
reidarT said:Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, ByRef nSize As Integer) As Integer
Public Function GetUserName() As String
Dim iReturn As Integer
Dim userName As String
userName = New String(CChar(" "), 50)
iReturn = GetUserName(userName, 50)
GetUserName = userName.Substring(0, userName.IndexOf(Chr(0)))
End Function
reidarT
"reidarT" <[email protected]> skrev i melding
How do I get current user logged in with vb.net code?
reidarT
no they are not the same
on a computer in a domain
Environment.UserName returns the username ( "Michel")
while My.User.Name returns ("domainName\Michel"
ofcourse you could split this but why would you ? if there is an alternative
regards
Michel Posseth
Theo Verweij said:Or: My.User.Name
Environment.UserName
regards
Michel Posseth [MCP]
:
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, ByRef nSize As Integer) As Integer
Public Function GetUserName() As String
Dim iReturn As Integer
Dim userName As String
userName = New String(CChar(" "), 50)
iReturn = GetUserName(userName, 50)
GetUserName = userName.Substring(0, userName.IndexOf(Chr(0)))
End Function
reidarT
"reidarT" <[email protected]> skrev i melding
How do I get current user logged in with vb.net code?
reidarT