Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 1, 1997

Getting UserID on Windows 95 and NT

You often want to get the user ID of the current user on the machine running Windows 95 or Windows NT. Use this simple wrapper function of an API function to do the job:
 
Option Explicit

Private Declare Function WNetGetUserA _
        Lib "mpr" (ByVal lpName As String, _
        ByVal lpUserName As String, _
        lpnLength As Long) As Long

Function GetUser() As String
        Dim sUserNameBuff As String * 255
        sUserNameBuff = Space(255)
        Call WNetGetUserA(vbNullString, _
                sUserNameBuff, 255&)
        GetUser = Left$(sUserNameBuff, _
                InStr(sUserNameBuff, _
                vbNullChar) - 1)
End Function
Jeff Hong
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date