|
-
Nov 25th, 1999, 07:03 AM
#1
Thread Starter
Lively Member
What set of commands would i use to tell me what user is logged on
-
Nov 25th, 1999, 08:24 AM
#2
Addicted Member
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
-
Nov 25th, 1999, 09:47 AM
#3
Hyperactive Member
Or, the exact same thing in fewer lines of code:
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
Yes, I'm bored.
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer
-
Nov 25th, 1999, 09:48 AM
#4
Hyperactive Member
Oh, BTW Keiko, You don't have to put a Me. in front of a control's name. Nothing important though.
-
Nov 25th, 1999, 10:36 AM
#5
Addicted Member
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).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|