How do I get Computer Name using .Net

How do I get Computer Name using .Net

ezcad.co.uk
Enthusiast Enthusiast
1,077 Views
3 Replies
Message 1 of 4

How do I get Computer Name using .Net

ezcad.co.uk
Enthusiast
Enthusiast

Hi All,

I am trying to migrate from Vlisp to C# .Net & occationally struggle with simple things. Some of my Vlisp applications have an "about" command which shows a product info dialog similar to the default AutoCAD product info dialog. However, in C#, I am struggling with the code to obtain the Computer Name as a string. Would someone please mind showing an example of the required syntax to retrieve the ComputerName property from WhoHasInfo (or anywhere else for that matter) so as it can be shown in a form. See attachment which shows the existing Vlisp dialog.

Any help much appreciated as always.

AutoCAD 2009/2010 on XP Pro SP3.

Steve

0 Likes
Accepted solutions (1)
1,078 Views
3 Replies
Replies (3)
Message 2 of 4

jeff
Collaborator
Collaborator

Have you looked at the System.Environment.MachineName Property

http://msdn.microsoft.com/en-us/library/z8te35sa.aspx

 

The System.Environment class has other information pertaing to local enviroment.

 

 

        ed.WriteMessage(Environment.MachineName);
        ed.WriteMessage(Environment.UserName);
        ed.WriteMessage(Environment.CurrentDirectory);

 

 

You can also find your answers @ TheSwamp
0 Likes
Message 3 of 4

ezcad.co.uk
Enthusiast
Enthusiast

Thanks for your prompt reply Jeff.

Presumably, (environment.machinename) returns a string which may then be assigned to a variable thus:

string compName = (environment.machinename)

Forgive me spelling things out like this but I do not have VS installed on the PC I am using at the moment.

Steve

0 Likes
Message 4 of 4

jeff
Collaborator
Collaborator
Accepted solution

yes sir

 

You can also find your answers @ TheSwamp