Reputation: 40223
Is there any way, other than referencing the Microsoft.VisualBasic.dll (such as as below in .NET 3) to retrieve to Computer Name
new Microsoft.VisualBasic.Devices.ServerComputer().Name
Upvotes: 3
Views: 2162
Reputation: 41378
You can use System.Windows.Forms.dll and the SystemInformation
class. You can also use System.Environment.MachineName
or System.Environment.GetEnvironmentVariable("COMPUTERNAME")
. And if you're really devoted, you can make a P/Invoke into user32.dll to call the appropriate Win32 API.
Upvotes: 4