Get computer name (StringBuilder parameter) : Native Windows Function « Windows « C# / CSharp Tutorial
- C# / CSharp Tutorial
- Windows
- Native Windows Function
using System;
using System.Runtime.InteropServices;
using System.Text;
class MainClass{
[ DllImport( "kernel32.dll" ) ]
static extern bool GetComputerName( StringBuilder name, ref ulong size );
[STAThread]
static void Main(string[] args)
{
ulong size = 256;
StringBuilder name = new StringBuilder( (int)size );
bool success = GetComputerName( name, ref size );
Console.WriteLine( name.ToString() );
}
}
JAVA2S