CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2001
    Location
    Trivandrum, Kerala, India
    Posts
    21

    User names in Windows NT

    Hai,

    I am developing an application for a Windows NT network. Now I would like to know the users logged in different workstations in the network. Is there a way to get around this?

    Thanks in advance.

    Kishore.



  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: User names in Windows NT


    'Informations here come from Api-Guide, a free tool you can download at:
    'http://www.allapi.net/
    '
    'The GetUserName function retrieves the user name of the current thread.
    'This is the name of the user currently logged onto the system.
    'Example
    'This project needs a timer
    private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (byval lpBuffer as string, nSize as Long) as Long
    private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (byval nBufferLength as Long, byval lpBuffer as string) as Long
    private Declare Function IsIconic Lib "user32" (byval hwnd as Long) as Long
    private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    Timer1.Interval = 100
    Timer1.Enabled = true
    Dim strTemp as string, strUserName as string
    'Create a buffer
    strTemp = string(100, Chr$(0))
    'get the temporary path
    GetTempPath 100, strTemp
    'strip the rest of the buffer
    strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)

    '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)

    'Show the temppath and the username
    MsgBox "Hello " + strUserName + Chr$(13) + "The temp. path is " + strTemp
    End Sub
    private Sub Timer1_Timer()
    Dim Boo as Boolean
    'Check if this form is minimized
    Boo = IsIconic(me.hwnd)
    'Update the form's caption
    me.Caption = "Form minimized: " + Str$(Boo)
    End Sub





    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jul 2001
    Location
    Trivandrum, Kerala, India
    Posts
    21

    Re: User names in Windows NT

    Dear Rater,

    Thank you for your reply. The code worked well for my local system. But what about other workstations in the network? It is important for me. Any reply will be very much appreciated.

    Thank you once again.

    Kishore.


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

Featured