• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Recognizing Username

How Visual Basic can recover username informed on NT Login on machine with Win95.

The Machine is with Win95 connecting on NT server.
0
mvianna
Asked:
mvianna
1 Solution
 
stefieCommented:
You have to use an API-call.
This should do the job:
* in a module, declare this function
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

* in your code, put this:
    Dim lSize As Long
    Dim sUser As String    
    lSize = 100
    Dim lRC As Long

    sUser = String(lSize, 0)
    lRC = GetUserName(sUser, lSize)
   

* check if lRC <> 0
your username = Trim(Left(sUser, lSize - 1))
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now