This one should do it:
 
Declare Function APIGetComputerName$() As String
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA"
    (lpBuffer As String, nSize As Integer) As Integer
 
Define MAX_COMPUTERNAME_LENGTH  31

'--------------------------------------------------------------------
'Determine the computer name --- example: Print "Computer: " + 
APIGetComputerName$()
'--------------------------------------------------------------------
Function APIGetComputerName$() As String
 
Dim nRc As Integer,
 szBuffer As String,
 nBuffSize As Integer
 
OnError GoTo ErrorOccured
 
 nBuffSize = MAX_COMPUTERNAME_LENGTH + 1
 szBuffer = String$(nBuffSize, Chr$(32))
 
 nRc    = GetComputerName(szBuffer, nBuffSize)
 APIGetComputerName$ = RTrim$(Left$(szBuffer, nBuffSize))
 
 Exit Function
'-------------------------
ErrorOccured:
 APIGetComputerName$ = "Unknown"
 
End Function
 
HTH,
 
Peter Horsbøll Møller 
GIS Developer, MTM 
Geographical Information & IT 
  
COWI A/S 
Odensevej 95 
DK-5260 Odense S. 
Denmark 
  
Tel     +45 6311 4900 
Direct  +45 6311 4908 
Mob     +45 5156 1045 
Fax     +45 6311 4949 
E-mail   <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] 
 <http://www.cowi.dk/gis> http://www.cowi.dk/gis 

COWI har fået ny hjemmeside. Ydelserne GIS og IT, kort, kortlægning, 3D 
visualisering og arealforvaltning ligger under SAMFUND. Se mere her : 
www.cowi.dk

COWI has changed its homepage. Our services within cadastre and 
landadministration, geodataproducts, mapping and GIS can be seen under SOCIETY. 
See our services here: www.cowi.com

-----Original Message-----
From: Percival, Mark [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 04, 2005 12:48 PM
To: '[email protected]'
Subject: MI-L Computer Name


Has anyone got a function to return the computer name (not the Username)?  I 
know I've seen it somewhere but can't remember!
 
Your help would be gratefully received.
 
Regards,
 
Mark Percival
Data Standards Manager
Customer & Business Services
Coventry City Council
Tel: 024 7683 2540

 


This e-mail and any files transmitted with it are confidential and are intended 
solely for the use of the addressee. If you have received this e-mail in error, 
you are requested to contact the sender immediately, and not to disclose or 
make use of this information. 

All e-mails are monitored by Coventry City Council IT Security, using Star 
Filtering Services.

The views contained in this e-mail are those of the author and not necessarily 
those of Coventry City Council.
______________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The service is 
powered by MessageLabs.

Reply via email to