tryusing System;
using System.Text;
using System.Runtime.InteropServices;[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool GetComputerName(
StringBuilder lpBuffer,
[MarshalAs(UnmanagedType.U4)] ref int lpnSize);int re=0;
StringBuilder buf = new StringBuilder("",1024);
int siz=1024;
bool bOK = GetComputerName(buf,ref siz);
Debug.WriteLine(buf.ToString());
using System.Text;
using System.Runtime.InteropServices;[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
[return:MarshalAs(UnmanagedType.Bool)]
public static extern bool GetComputerName(
StringBuilder lpBuffer,
[MarshalAs(UnmanagedType.U4)] ref int lpnSize);int re=0;
StringBuilder buf = new StringBuilder("",1024);
int siz=1024;
bool bOK = GetComputerName(buf,ref siz);
Debug.WriteLine(buf.ToString());
解决方案 »
- 这个TextBox事件怎么写?
- 翻译字典的设计思路
- 把“动态代理类”注册成Remoting服务,客户端调用时失败----->100分求解
- 求Smart Client程序框架源码
- 我从webBrowser1.DocumentText得到内容放到textBox.txt中不能显示中文汉字.
- 怎么让WebForm居中显示(或许是我太菜了,上次回答的我没试出来这次贴代码)?
- 关于Remoting中动态发布服务器对象遇到的一点问题
- 我刚想学C#,菜鸟请教问题
- 如何在.NET中文版本中发布英文包
- 怎样自定义工具栏
- 如何用.net验证windows用户的身份?
- 关于安装vs.net开发环境的奇怪问题,多多关注
2. GetComputerName will fill the name in the first parameter you pass in, so you need to give it a StringBuilder or a byte[]
3. it also changes the last parameter to let you know how many long the name is