Results 1 to 4 of 4

Thread: API doubt!!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Hi friends,
    Im new to API. I want to know the user name who has logged in the machine. What API should I use?
    Pls help!!!

    Cheers
    Parasuraman
    Om Nama Sivaya!!!

  2. #2
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Use the GetUserName API:

    Code:
    Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  3. #3
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224
    Since you are new to API stuff I add this too..

    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


    Private Sub Your_Sub()
    Dim strUSerName As String
    'Create a buffer
    strUserName = String(100, Chr$(0))
    'Get the username
    GetUserName strUserName, 100
    'strip the rest of the buffer
    strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)

    MsgBox "Hello " + strUserName
    End Sub
    If you can't pronounce my name, call me GURU

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Thanx alot CyeberCarsten and Kumar
    Its working excellent.

    Thanx alot again

    Parasuraman
    Om Nama Sivaya!!!

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