Results 1 to 5 of 5

Thread: Username

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    67

    Post

    What set of commands would i use to tell me what user is logged on

  2. #2
    Addicted Member
    Join Date
    Sep 1999
    Posts
    229

    Post


    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

  3. #3
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    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

  4. #4
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    Oh, BTW Keiko, You don't have to put a Me. in front of a control's name. Nothing important though.

  5. #5
    Addicted Member
    Join Date
    Sep 1999
    Posts
    229

    Post


    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
  •  



Click Here to Expand Forum to Full Width