Results 1 to 3 of 3

Thread: [RESOLVED] Calling user

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Resolved [RESOLVED] Calling user

    Hi all!
    We have a vb6 application exe that is in a shared server directory
    All the user have a link to that exe
    It's there a way (inside the exe) to know which user is executing the exe?
    Something like Environ function but for a shared exe
    Welcome to any idea or link
    Thanks
    (We have the source files also)

    JG

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Calling user

    You can use GetUserName api function (declaration below) and log it a local file or better yet database with start/end date and time.
    Code:
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: [RESOLVED] Calling user

    Thanks Rhinobull, that's what I wanted
    I'll remember to search API functions
    Here's the code in case someone need it

    Code:
    'General Declarations
    Option Explicit
    
    Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    
    Dim GUNlpBuff       As String * 255
    Dim GUNret          As Long
    Dim GUNUserName     As String
    .
    .
    .
    Private Sub Form_Load()
    
        GUNret = GetUserName(GUNlpBuff, 255)
        GUNUserName = Left(GUNlpBuff, InStr(GUNlpBuff, Chr(0)) - 1)
        MsgBox GUNUserName
    
    End Sub

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