Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

GetUserName Function - Windows API

RSS
Modified on Mon, Jul 09, 2012, 1:23 PM by Administrator Categorized as Windows API

Purpose

Returns the username of the current Windows user

Code

VB6

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

Public Function GetUserName()

    Dim result As String
    Dim n As Long
    Dim retval As Long
    
    n = 255
    result = Space$(n)
    retval = GetUserNameApi(result, n)
    GetUserName = Left$(result, n - 1)

End Function

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.