[AccessD] Get Computer Name

Heenan, Lambert Lambert.Heenan at chartisinsurance.com
Fri Aug 14 14:10:37 CDT 2009


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




More information about the AccessD mailing list