Sandro Bizioli


Chi sogna di giorno conosce molte cose che sfuggono a chi sogna soltanto di notte. (E.A.Poe)
Mappa

Recuperare il nome dell'utente attualmente loggato

Questo semplice esempio restituisce il nome dell'utente attualmente loggato a Windows.
Il sorgente è compatibile con Visual Basic 5 e Visual Basic 6

 

Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, byRef nSize As Long) As Long

Public Function GetUName() As String
'***********************************************************************
'Func.: GetUName (SB-29/03/2000; Mod.: )
'Desc.: Restituisce l'user name d'accesso a Windows
'Par. :
'Ret. : Stringa con il nome dell'utente corrente
'***********************************************************************
Dim sBuffer As String
Dim lSize As Long
  sBuffer = Space(256)
  lSize = Len(sBuffer)
  Call GetUserName(sBuffer, lSize)
  If lSize > 0 Then
    GetUName = Left(sBuffer, lSize - 1)
  Else
    GetUName = ""
  End If
End Function

Categoria: VB6
martedì, 27 feb 2007 Ore. 13.55
Statistiche
  • Views Home Page: 109.879
  • Views Posts: 560.130
  • Views Gallerie: 108.931
  • n° Posts: 227
  • n° Commenti: 222
Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003