Click to See Complete Forum and Search --> : Getting Computer's Name


mpiyesizwe
March 30th, 2001, 07:01 PM
Please may someone let me know how I can get the computer's name in VB code.

Thanks

d.paulson
March 30th, 2001, 07:17 PM
In a module

option Explicit

Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (byval lpBuffer as string, nSize as Long) as Long




In a form

option Explicit

private Sub Form_Load()

Dim sComputer as string
Dim lpBuff as string * 1024

'get the Computer Name
GetComputerName lpBuff, len(lpBuff)
sComputer = Left$(lpBuff, (InStr(1, lpBuff, vbNullChar)) - 1)
lpBuff = ""

MsgBox "Computer Name: " & sComputer

End
End Sub





David Paulson

Cimperiali
April 4th, 2001, 05:27 AM
Great. If the one who asked do not rate, I do.

Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.