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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function to return machine name?

Status
Not open for further replies.

elziko

Programmer
Nov 7, 2000
486
GB
Cant find anything in the help file. Anyone got something similar?

Thanks
 
'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Insert this code to the module :

Declare Function GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

'Insert this code to your form:

Private Sub Form_Load()
MsgBox sGetComputerName
End Sub

Function sGetComputerName() As String
Dim sBuffer As String
Dim lBufSize As Long
Dim lStatus As Long
lBufSize = 255
sBuffer = String$(lBufSize, " ")
lStatus = GetComputerName(sBuffer, lBufSize)
sGetComputerName = ""
If lStatus <> 0 Then sGetComputerName = Left(sBuffer, lBufSize)
End Function


Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top