Click to See Complete Forum and Search --> : Grabbing Computer Name


November 12th, 1999, 10:20 AM
How can I grab the computer name? As in the name Netbios would give the system.

Sanjeeev
November 12th, 1999, 05:50 PM
copy paste the code in a new application


option Explicit

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

private Sub Command1_Click()
Dim ret as Long
Dim buff as string
buff = Space(255)

ret = GetComputerName(buff, 255)
MsgBox buff
End Sub

November 15th, 1999, 05:31 AM
Use API's:
For instance toget computer name
use GetComputerName function.
Similarly if want to get hold of the current user name then use API
GetUserName.
Use VB Application wizard to get to see how to use these calls as the wizard
automatically generates the code for you.