日期:2014-05-17 浏览次数:21132 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace API_GetUserName_取得当前用户的名字
{
class Program
{
[DllImport("advapi32.dll", EntryPoint = "GetUserName")]
public static extern int GetUserName(
string lpBuffer,
ref int nSize
);
static void Main(string[] args)
{
string str = "0000000";
int b = 6;
int a=199;
b=GetUserName(str,ref a);
Console.WriteLine(str);
Console.WriteLine(a.ToString());
Console.WriteLine(b.ToString());
}
}
}