| {\rtf1\ansi\ansicpg1252\deff0\deflang1044{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}} \viewkind4\uc1\pard\f0\fs17 The code to get the username of the logged in user is almost identical to the code used to find the computer's name. \par \par 'Place in General Declarations section: \par Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long \par \par \par Use the following code to find the username. \par \par Dim strUserName As String * 255 \par Dim lngUserNameLength As Long \par \par lngUserNameLength = Len(strUserName) \par If GetUserName(strUserName, lngUserNameLength) <> 0 Then \par MsgBox Left$(strUserName, lngUserNameLength) \par Else \par MsgBox Err.LastDllError \par End If \par } |
Getting the Username of the Logged in user |
India web developer web development India | India web development company India ecommerce web developer