Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / November 2007



Tip: Looking for answers? Try searching our database.

computer name from within a script or a visual Basic

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sebastian Seghete - 23 Nov 2007 17:22 GMT
Hello there,
How do I get the computer name from within a script or a visual Basic
program!

May thanks

Sebastian
Anthony Jones - 23 Nov 2007 22:33 GMT
> Hello there,
> How do I get the computer name from within a script or a visual Basic
> program!
>
> May thanks

Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA"
(ByVal lpBuffer As String, nSize As Long) As Long

Public Property Get ComputerName() As String

   Dim lMaxNameLength as Long

   Dim sComputerName As String

   lMaxNameLength = 255

   sComputerName = String$(lMaxNameLength , 0)

   If GetComputerName(sComputerName, lMaxNameLength ) <> 0 Then

       ComputerName = Left$(sComputerName, InStr(1, sComputerName,
vbNullChar) - 1)

   Else

       Err.Raise 1001, "GetComputerName", "Failed to get computer name"

   End If

End Property

Signature

Anthony Jones - MVP ASP/ASP.NET

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.