Get User Server Name


‘Task: How to get user server name [Computer name] when he login on network.

‘Declarations
Private Declare Function GetComputerName Lib “kernel32” Alias “GetComputerNameA” (ByVal lpBuffer As String, nSize As Long) As Long

‘Code:
Private Sub Form_Load()
Dim dl,cnt As Long
Dim s As String
cnt = 200
s = Space$(cnt)
dl = Len(s)
Call GetComputerName(s, dl)
Text1.Text = Left$(s, dl)
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s