Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get the Computer Name

Status
Not open for further replies.

abdullauthan

Programmer
Apr 20, 2000
64
SA
How can I get the computer name of the PC. Is there any way without using the registry?
 
Public Declare Function GetComputerName Lib &quot;kernel32&quot; Alias &quot;GetComputerNameA&quot; (ByVal lpBuffer As String, nSize As Long) As Long<br><br>Public Function WorkStation() As String<br><br>Dim sBuffer As String<br>Dim lSize As Long<br><br>&nbsp;&nbsp;&nbsp;&nbsp;sBuffer = Space$(255)<br>&nbsp;&nbsp;&nbsp;&nbsp;lSize = Len(sBuffer)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Call GetComputerName(sBuffer, lSize)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If lSize &gt; 0 Then _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WorkStation = Left$(sBuffer, lSize)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Function<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top