How do I find out which user is logged in?
Under Windows 95, the computer can be set up so that many different users can log into the computer. The name of current user can be retrieved by using the following code.
Dim s As String Dim cnt As Long Dim dl As Long Dim CurUser as String cnt = 199 s = String$(200, 0) dl = GetUserName(s, cnt) If dl <> 0 Then curuser = Left$(s, cnt) Else curuser = ""
You must declare the following function in the declarations section of a form or module in the project.
Declare Function GetUserName Lib "advapi32.dll" Alias _ "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _ As Long