borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincani
:: How to Obtain the name of the current user logged...

Author  

Andrea Tincani

Language  

VB5, VB6

Operating Systems  

Windows 95, 98 and NT
API Declarations

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

Module

Public Function UserName() As String
    Dim cn As String
    Dim ls As Long
    Dim res As Long

    cn = String(1024, 0)
    ls = 1024
    res = GetUserName(cn, ls)
    If res <> 0 Then
        UserName = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
    Else
        UserName = ""
    End If
End Function

:: Navigation

Home

Miscellaneous API Tips

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 26-10-2007 Re: Coma and dot separator for decimal numbers by yronium
icon 04-04-2007 Re: have some problem when showing item from database to listbox by yronium
icon 12-03-2006 Recordset by nounabarbie
icon 03-03-2006 Domain Registration by ~Bean~
icon 07-02-2006 Re: Programmatically set NTFS folder permissions. by Goran
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder