Get computer name (StringBuilder parameter) : Native Windows Function : Windows C# Examples


C# Examples » Windows » Native Windows Function »

 

Get computer name (StringBuilder parameter)









    
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()  );
    }
}
    
   
  
   



Output

navioo


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Windows
» Native Windows Function