What set of commands would i use to tell me what user is logged on
Printable View
What set of commands would i use to tell me what user is logged on
Hi Death,
You can use this set of commands.
----------------------
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal rsBuffer As String, rlSize As Long) As Long
Option Explicit
Private Sub Form_Load()
Dim dsBuffer As String
Dim dlSize As Long
dsBuffer = Space$(255)
dlSize = Len(dsBuffer)
Call GetUserName(dsBuffer, dlSize)
If (dlSize > 0) Then
Me.txtUserID.Text = Left$(dsBuffer, dlSize)
Else
Me.txtUserID.Text = vbNullString
End If
End Sub
-------------
Does it help ?
Regards
Or, the exact same thing in fewer lines of code:
Yes, I'm bored.Code:Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal rsBuffer As String, rlSize As Long) As Long
Private Sub Form_Load()
Dim dsBuffer As String, dlSize As Long
dsBuffer = Space$(255)
dlSize = Len(dsBuffer)
Call GetUserName(dsBuffer, dlSize)
If (dlSize > 0) Then txtUserID.Text = Left$(dsBuffer, dlSize) Else txtUserID.Text = "UNKNOWN USER"
End Sub
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer
Oh, BTW Keiko, You don't have to put a Me. in front of a control's name. Nothing important though.
Compwiz,
I believe the purpose of this forum is to help each other.
I can write a very compact code, but it may be difficult for others to read. As long as the concept is there, the questioners can re-structure the code in their ways.
Also, I know "Me" kind of thing. This morning I just made a fast Cut and Paste from my original code.
Any more comment kid ?
[This message has been edited by Keiko (edited 11-25-1999).]