|
-
Jul 26th, 2005, 05:47 AM
#1
Re: Help on retrieving Local Computer Name
There is an API function you can use. Here's a wrapper function for that API function.
VB Code:
Private Declare Function GetComputerName _
Lib "kernel32.dll" Alias "GetComputerNameA" ( _
ByVal lpBuffer As String, _
ByRef nSize As Long) As Long
Public Function GetCompName() As String
Dim sBuff As String
Dim nLen As Long
nLen = 215 'probably to large buffer
sBuff = Space$(nLen + 1)
If GetComputerName(sBuff, nLen) Then
GetCompName = Left$(sBuff, nLen)
Else
sBuff = Space$(nLen)
Call GetComputerName(sBuff, nLen)
GetCompName = Left$(sBuff, nLen)
End If
End Function
-
Jul 26th, 2005, 06:39 AM
#2
New Member
Re: Help on retrieving Local Computer Name
Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetUserName() As String
Dim UserName As String * 255
Call GetUserNameA(UserName, 255)
GetUserName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)
End Function
Public Function GetComputerName() As String
Dim UserName As String * 255
Call GetComputerNameA(UserName, 255)
GetComputerName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)
End Function
'Put in module
'Call this like
'Text1.text = "Hello " & GetUserName & " On " & GetComputerName
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|