Tuesday, May 5, 2009

To get user's Server name.

below is the code that can retrieve the server name of user logged in.


'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)
TxtServer.Text = Left$(s, dl)
End Sub

No comments:

Post a Comment