|
 |
access thread: retrieving local host name
Message #1 by Diane Roberts <Diane.Roberts@c...> on Wed, 27 Feb 2002 09:26:43 -0600
|
|
I would like to retrieve the machine name of a user in the VBA code
behind a form and use it. This database does not have security set up
for it. The VB Winsock control has a LocalHostName property that
returns this information, but the control in Access 2000 does not. Any
quick help please?
--
CONFIDENTIALITY NOTICE
This message and any included attachments are from CashRetriever
Systems, Inc. (CSI), and are intended only for the parties identified
above. The information contained in this message is confidential and
the unauthorized forwarding, printing, copying, distributing, or using
such information is strictly prohibited and may be unlawful. If you
have received this transmission in error, please immediately notify the
sender by return email or by telephone at (205) 733-9925.
Message #2 by "Hamilton, Tom" <hamiltont@s...> on Wed, 27 Feb 2002 07:43:00 -0800
|
|
Hi Diane - try this
Add this to the Declaration section
Declare Function GetComputerName& Lib "kernel32.dll" _
Alias "GetComputerNameA" (ByVal lpBuffer As String, _
nSize As Long) '
Network CPU Name
Declare Function GetUserName& Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) '
Network login name
Public Const MAX_COMPUTERNAME_LENGTH = 15 ' Varies with
platform OS
'*******************************************************************
' Then add this/these functions to your module - see the usage note for
clarification
Function sGetComputer() ' Returns network
name of computer
' Usage: ="Computer Name: " & sGetComputer()
Dim s$
s$ = String$(MAX_COMPUTERNAME_LENGTH + 1, 0)
Dim dl&
Dim sz&
sz& = MAX_COMPUTERNAME_LENGTH + 1
dl& = GetComputerName(s$, sz)
sGetComputer = Left$(s$, sz)
End Function
Function sGetUser() As String ' Returns current
network logon
' Usage: ="Network User Name: " & sGetUser()
Dim s$, cnt&, dl&, sWho As String
cnt& = 199
s$ = String$(200, 0)
dl& = GetUserName(s$, cnt)
sGetUser = Left$(s$, cnt - 1)
End Function
>>> Diane Roberts 02/27/02 07:26AM >>>
I would like to retrieve the machine name of a user in the VBA code
behind a form and use it. This database does not have security set up
for it. The VB Winsock control has a LocalHostName property that
returns this information, but the control in Access 2000 does not. Any
quick help please?
--
CONFIDENTIALITY NOTICE
This message and any included attachments are from CashRetriever
Systems, Inc. (CSI), and are intended only for the parties identified
above. The information contained in this message is confidential and
the unauthorized forwarding, printing, copying, distributing, or using
such information is strictly prohibited and may be unlawful. If you
have received this transmission in error, please immediately notify the
sender by return email or by telephone at (205) 733-9925.
|
|
 |