我想用CreateProcess函数来执行控制台程序,但是在C#中没有PSECURITY_ATTRIBUTES结构的定义,而且C#中不支持指针,所以不能使用CreateProcess函数,求教高手C#中怎样调用控制台程序,并向其传递命令行参数的方法。谢谢!!

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4627/4627371.xml?temp=.2907678
      

  2.   

    public string GetCustomerMac(string clientIP) {  string mac = ""; System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = "nbtstat"; process.StartInfo.Arguments = "-a "+clientIP; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardOutput = true; process.Start(); string output = process.StandardOutput.ReadToEnd(); int length = output.IndexOf("MAC Address = "); if(length>0) { mac = output.Substring(length+14, 17); } process.WaitForExit(); return mac.Replace("-", "").Trim(); }