Using VB6, how do I get the current user and domain on Windows XP?
问题 I need the current user and the domain. I am using a VB 6 application. Thanks 回答1: One way would be to ask the environment: Dim UserName As String Dim UserDomain As String UserName = Environ("USERNAME") UserDomain = Environ("USERDOMAIN") (Works on Windows NT and up only, obviously.) 回答2: And the API-version: Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Declare Function LookupAccountName Lib "advapi32.dll" Alias