[AccessD] Get Computer Name

Max Wanadoo max.wanadoo at gmail.com
Fri Aug 14 15:43:49 CDT 2009


Hi Lambert,
Of course, you are correct, but you could also pick it up from the Registry.

HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Registration\
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\
LogonUI

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerN
ame
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName



The above are just some of the entries. 

Access give you the opportunity t write to the registry and also to read
from it.

Alternative, that's all.

Max


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: 14 August 2009 21:28
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Get Computer Name

That's the point (the first one): someone else can alter your environment
variables at boot up, and then the cat is out of the bag.

As for the second point: if you use the API to get user name and computer
name then the environment variables are irrelevant. 

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Friday, August 14, 2009 4:13 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Get Computer Name

Hmm, not heard that Lambert, but you can always set your own environment
variables on boot up.

Max


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: 14 August 2009 21:05
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Get Computer Name

I've read reports that Environ is considered insecure by later versions of
Access/Office (because what it returns can be manipulated by intruders), but
the API is trusted. 

Also some shops do not actually set the  'COMPUTERNAME" and/or "USERNAME"
environment variables, so Environ will return nothing.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Reuben Cummings
Sent: Friday, August 14, 2009 3:18 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Get Computer Name

Is there an advantage to the API over the environ function?

Reuben Cummings
GFC, LLC
812.523.1017


> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, 
> Lambert
> Sent: Friday, August 14, 2009 3:11 PM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Get Computer Name
> 
> 
> Use the API...
> 
> 
> Private Declare Function apiGetComputerName Lib "kernel32" Alias _
>     "GetComputerNameA" (ByVal lpBuffer As String, nSize As
> Long) As Long
> 
> 
> 'This code was originally written by Dev Ashish.
> 'It is not to be altered or distributed, 'except as part of an 
> application.
> 'You are free to use it in any application, 'provided the copyright 
> notice is left unchanged.
> '
> 'Code courtesy of
> 'Dev Ashish
> Function fOSMachineName() As String
> 'Returns the computername
> Dim lngLen As Long, lngX As Long
> Dim strCompName As String
>     lngLen = 16
>     strCompName = String$(lngLen, 0)
>     lngX = apiGetComputerName(strCompName, lngLen)
>     If lngX <> 0 Then
>         fOSMachineName = left$(strCompName, lngLen)
>     Else
>         fOSMachineName = ""
>     End If
> End Function
> 
> '******************** Code End **************************
> 
> Lambert
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
> Sent: Friday, August 14, 2009 2:58 PM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Get Computer Name
> 
> Reuben,
> 
> With A2003 running on vista Home Edition on PC running OS of x64, the
> Environ("ComputerName") returns the computer name
> 
> Max
> 
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Reuben 
> Cummings
> Sent: 14 August 2009 19:49
> To: AccessD
> Subject: [AccessD] Get Computer Name
> 
> I need to retrieve the computer name of the computer currently running 
> a function.
> 
> Using A2k...will Environ("ComputerName") still work in Vista? 
>  I don't have a Vista computer to test it.
> 
> Thanks.
> 
> Reuben Cummings
> GFC, LLC
> 812.523.1017
> 
> 
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 



--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list