Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Computer Name

Status
Not open for further replies.

astonmak

MIS
Feb 14, 2003
41
0
0
CN
Dear all,

How to get the user computer name? I belive there is a API working with it.

Thanks
Aston
 
Option Explicit
Private Declare Function GetComputerName Lib "kernel32.dll" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Command1_Click()
Dim strCompName As String
Dim rVal As Long
Dim lngLen As Long
strCompName = Space(255)
lngLen = 255
rVal = GetComputerName(strCompName, lngLen)
MsgBox Left(strCompName, lngLen)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top