Advertisement
2002C Internet/ HTML #9964

Getting the User Name

By calling this function you can retrieve the current user name on that computer. Enjoy!

AI

Yapay Zeka Özeti: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kaynak Kod
original-source
Place the following code into a module:
Private Declare Function GetUserName Lib "advapi32.dll" _
      Alias "GetUserNameA" (ByVal lpBuffer As String, _
      nSize As Long) As Long
Public Function UserName() As String
  Dim llReturn As Long
  Dim lsUserName As String
  Dim lsBuffer As String
  
  lsUserName = ""
  lsBuffer = Space$(255)
  llReturn = GetUserName(lsBuffer, 255)
  
  
  If llReturn Then
    lsUserName = Left$(lsBuffer, InStr(lsBuffer, Chr(0)) - 1)
  End If
  
  UserName = lsUserName
End Function
 
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı