Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

computer name

Hi,
Can u tell me how i can read computer name in VB6. fazi
0
mfazi
Asked:
mfazi
1 Solution
 
StonedRaiderCommented:
use GetComputerName API function
0
 
DhaestCommented:
2 possibilities:

  MsgBox Environ$("computername")

(see http://www.developerfusion.com/show/1640/show.aspx for more information)

or

Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
  Dim dwLen As Long
 Dim strString As String
 'Create a buffer
 dwLen = MAX_COMPUTERNAME_LENGTH + 1
 strString = String(dwLen, "X")
 'Get the computer name
 GetComputerName strString, dwLen
 'get only the actual data
 strString = Left(strString, dwLen)
 'Show the computer name
 MsgBox strString
End Sub
0
 
freeman200Commented:
Add a Winsock component.

MsgBox Winsock1.LocalHostName

Thats it...
0
 
CleanupPingCommented:
mfazi:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Accept Dhaest's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now