Private Declare Function GetComputerName& Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long)
Private Declare Function GetUserName& Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long)
Private Function ComputerName() As String
Dim s As String, l As Long
l = 15
s = String(l, Chr(32))
GetComputerName s, l
ComputerName = Left$(s, l)
End Function
Private Function UserName() As String
Dim s As String, l As Long
l = 255
s = String(l, Chr(32))
GetUserName s, l
UserName = Left$(s, l)
End Function
Tuesday, December 16, 2008
[vb6] Read the computer name and current user name
These functions may be used to retrieve the computer name and the name of the current user (or at least the names as they are known to the operating system).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment