Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Unanswered: FoxPro: Retrieve NT Username

    I'm afraid I'm not entirely sure what version of FoxPro I am using (at a guess v5 or 6) but hopefully any solution can be "moulded" to work on my platform.

    Is it possible to retrieve the NT username of a user of a foxpro application, and if so, how?

    Cheers,
    George
    George
    Home | Blog

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    *---+ Get Windows NT Username
    private lcUserIDBuffer, lnBufferSize, RetVal
    
    RetVal         = 0
    lcUserIDBuffer = Space(25) && Return buffer for user ID string
    lnBufferSize   = 25        && Size of user ID return buffer
    
    Declare Integer GetUserName In Win32API As GetName;
            String  @lcUserIDBuffer,;
            Integer @lnBufferSize
    
    RetVal = GetName(@lcUserIDBuffer, @lnBufferSize)
    
    lcNTUsername = Left(lcUserIDBuffer, lnBufferSize-1)
    
    If empty(lcNTUsername)
    	lcNTUsername = "Unknown"
    EndIf
    *---+ Username retrieved.
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •