c#.net使用WinAPI: GetComputerName - 获取计算机名称
2012-03-28 13:49
543 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace GetLocalIpApp { class Program { [DllImport("kernel32.dll")] static extern bool GetComputerName(IntPtr p, ref int lpnSize); static void Main(string[] args) { string strLocalName = LocalComputerName(); Console.WriteLine(strLocalName); Console.Read(); } static string LocalComputerName() { IntPtr p = Marshal.AllocHGlobal(128); int len = 128; GetComputerName(p, ref len); string strName = Marshal.PtrToStringAnsi(p); //释放指针占用的内存 Marshal.FreeHGlobal(p); return strName; } } }
相关文章推荐
- WinAPI: GetComputerName - 获取计算机名称
- WindowsAPI使用详解——GetComputerName|GetUserName 获取电脑名称和当前用户名
- GetComputerName 获取计算机名称
- WindowsAPI使用详解——GetComputerName|GetUserName 获取电脑名称和当前用户名
- GetComputerName正确获取中英文计算机名
- 使用gethostname()和gethostbyname()获取IP地址和计算机名
- IE9 使用document.getElementsByName("abc") 不能获取到名称相同SPAN元素
- 使用GetEnumName和GetEnumValue获取枚举类型的名称和数值
- WinAPI: SetComputerName - 更改计算机名称
- GetComputerName正确获取中英文计算机名
- GetComputerNameEx函数检索与本地计算机相关联的NetBIOS或DNS名称。
- C# .net 获取计算机名 IP
- VC中使用GetModuleFileName获取应用程序路径(转)
- Div使用name属性实现通过getElementsByName获取Div集的方法
- VC++ 得到计算机名和用户名 GetComputerName GetUserName
- c#(WinForm)遍历局域网计算机(电脑)获取IP和计算机名称
- VC中使用GetModuleFileName获取应用程序路径(整理)
- VC中使用GetModuleFileName获取应用程序路径
- c#(WinForm)遍历局域网计算机(电脑)获取IP和计算机名称(转)
- Atitit. 数据库-----catalog与schema的设计区别以及在实际中使用 获取数据库所有库表 java jdbc php c#.Net