name of the computer where VB.Net program is running.

  • Thread starter Thread starter Sender
  • Start date Start date
S

Sender

I need the "name of the computer" where the VB.Net program is running, as I
need to compare it with some string. How do I get that name using code?
 
Easy way on NT/XP computer is
Dim sData As string = Environment.GetEnvironmentVariable("COMPUTERNAME")



Regards
Fredrik Melin
 
Hi Fredrik, while that is a perfectly valid way to do it, IMO it's not
exactly reliable, so I tend to avoid it. Environment variables can be
changed at any time, a more concrete way would be to call
System.Net.Dns.GetHostName or use the Environment class to retrieve the
name.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
I need the "name of the computer" where the VB.Net program is running

There also is "SystemInformation.ComputerName".
Note that this requires the System.Windows.Forms reference.


Kevin
 
Back
Top