954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Get the name of this computer

0
By SleepDepD on Sep 20th, 2004 6:07 pm

Get the name of this computer

Public Declare Function GetLocalComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nsize As Long) As Long
 
Public Function GetComputerName() As String
'==================================
'==================================
Dim strComputerName	 As String
Dim lngResult		 As Long
 
'-- Set up buffer.
strComputerName = String$(255, 0)
 
'-- Make the call.
lngResult = GetLocalComputerName(strComputerName, 255)
 
'-- Clean up and assign the value.
If lngResult = 1 Then GetComputerName = Left$(strComputerName, InStr(1, strComputerName, vbNullChar) - 1)
End Function

Would it not be easier to use ?

enum("COMPUTERNAME")

jwshepherd
Junior Poster
123 posts since Jun 2005
Reputation Points: 20
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You