473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Host Name or Computer Name

Hi,
Who can I get hostname of local machine?

I have found following, but I am not sure all Windows OS(XP/2000/NT/98..) will have the "COMPUTERNAME" environment variable.

System.Environment.GetEnvironmentVariable("COMPUTE RNAME");

Is there any better & more reliable way to get hostname/computer name of local machine, where my application are going to run?

Thanks,
Avin Patel
Nov 16 '05 #1
2 40070
You should try the following:

System.Windows.Forms.SystemInformation.ComputerNam e
Lajos Malozsák

"Avin Patel" <Av*******@discussions.microsoft.com> wrote in message
news:4B**********************************@microsof t.com...
Hi,
Who can I get hostname of local machine?

I have found following, but I am not sure all Windows OS(XP/2000/NT/98..) will have the "COMPUTERNAME" environment variable.
System.Environment.GetEnvironmentVariable("COMPUTE RNAME");

Is there any better & more reliable way to get hostname/computer name of local machine, where my application are going to run?
Thanks,
Avin Patel

Nov 16 '05 #2
Try this.

string myHostName = System.Net.Dns.GetHostName();

or

string myHostName = Environment.MachineName;

Shak.

"Avin Patel" <Av*******@discussions.microsoft.com> wrote in message
news:4B**********************************@microsof t.com...
Hi,
Who can I get hostname of local machine?

I have found following, but I am not sure all Windows OS(XP/2000/NT/98..) will have the "COMPUTERNAME" environment variable.
System.Environment.GetEnvironmentVariable("COMPUTE RNAME");

Is there any better & more reliable way to get hostname/computer name of local machine, where my application are going to run?
Thanks,
Avin Patel

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Uzi Baruch | last post by:
Hi! i want to know if i have an ip address of a computer and its DNS server name, if their is an windows API that can resolve the computer name of the given ip address. or vice verca -...
9
by: Dan Nash | last post by:
Heylo I want to be able to get the computer name from my C# page. Is this possible? Basically, I'm developing a auto-bugreport feature for an intranet and want to know which machine sent the...
5
by: z. f. | last post by:
i need to get the computer name from an aspx page. i use System.Windows.Forms.SystemInformation.ComputerName() and it's working fine, but in second thought, it might not be recomended to use the...
0
by: Ricky Chan | last post by:
I am using DNSQuery API to get computer name from IP address. However, by below sample code, I don't know how to specify the DNS Address for the field (ByVal aipServers As Integer). any idea?...
1
by: ad | last post by:
I want to get some data for log. How can we get the use's IP and computer name?
5
by: ThunderMusic | last post by:
Hi, I want to find the computer name and the company name from the network indentification informations. For the computer name, I found System.Net.Dns.GetHostName(), but I fgound nothing for...
0
by: BrianT | last post by:
I'm trying to build code that allows the computer name to be changed, then asks the user to reboot to make the change affective. I got the code working when logged in as the local computer...
1
by: kartik369 | last post by:
This code gets the IP address from the computer name we already know. I wanted to know how can we get the computer name if we know the IP address. Thanks void AsyncServer::InitSocks() {...
8
by: =?Utf-8?B?QkRSaWNoYXJkc29u?= | last post by:
I am aware that is is possible to determine the web client computer name using DNS, i.e. invoke System.Net.Dns.GetHostEntry( System.Web.HttpRequest.UserHostAddress). However, this only seems to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.