Duane's USER_NAME function is just a
wrapper for the API, so I think his post really amounts to one method, not
two.
Take into account that other applications can and sometimes
do modify the Environ$ variables - therefore they may not be as
reliable.
Tom Oakes
Personal PC Consultants, Inc.
[EMAIL PROTECTED]
503.230.0911 (O)
402.578.2648 (C)
512.727.9497 (F)
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Richard
Sent: Wednesday, January 25, 2006 9:14 AM
To: [email protected]
Subject: [AccessDevelopers] Re: Finding paths to special folders.
Check this code in Access:
for the Username:
MsgBox (Environ("username"))
and for the computer name:
MsgBox (Environ("computername"))
put those consecutive in the Load sub of a form and you should get
two dialog boxes - the first showing the user ID currently logged in,
the second showing the name of the CPU on the network.
HTH!
Alienwebmaster
--- In [email protected], "Duane Hennessy"
<[EMAIL PROTECTED]> wrote:
...
> You can grab the user name on of two ways:
> Via API:
> Private Declare Function GetUserName Lib "advapi32.dll" _
> Alias "GetUserNameA" (ByVal Buffer As String, Size As Long) As
Long
>
> Public Function Get USER_NAME() As String
> 'Author: Duane Hennessy
> 'Date: 7.4.2003
> 'Description: Returns the user name
> 'Requirements: GetUserName
> On Error Resume Next
> Dim strUserName As String
> Const lngcLength As Long = 255
> Dim lngResult As Long
>
> strUserName = String(255, 0)
> lngResult = GetUserName(strUserName, lngcLength)
> USER_NAME = left$(strUserName, InStr(1, strUserName, Chr(0)) -
1)
> End Function
Please zip all files prior to uploading to Files section.
SPONSORED LINKS
| Microsoft access developer | Microsoft access help | Microsoft access database |
| Microsoft access training | Microsoft access training course | Microsoft access programming |
YAHOO! GROUPS LINKS
- Visit your group "AccessDevelopers" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
