Get computer name in C # without link to Microsoft.VisualBasic.dll

Is there a way, besides the link to Microsoft.VisualBasic.dll (for example, as shown below in .NET 3) to get the computer name

new Microsoft.VisualBasic.Devices.ServerComputer().Name
+3
source share
2 answers

Use System.Environment.MachineName.

+15
source

You can use System.Windows.Forms.dll and the class SystemInformation. You can also use System.Environment.MachineNameor System.Environment.GetEnvironmentVariable("COMPUTERNAME"). And if you are truly loyal, you can do P / Invoke in user32.dll to call the corresponding Win32 API.

+4
source

Source: https://habr.com/ru/post/1737265/


All Articles