zoukankan      html  css  js  c++  java
  • StackTrace 进程

    代码
    public BaseForm()
    {
    InitializeComponent();
    StackTrace st
    = new StackTrace(true);
    //this.Text = st.FrameCount.ToString();
    Label lbl = new Label();
    //lbl.Text = st.FrameCount.ToString();
    //lbl.Text = st.GetFrame(1).GetFileName();

    //这两种方法都可以取到类信息
    string s1= st.GetFrame(1).GetMethod().DeclaringType.Name;

    string s2 = st.GetFrame(1).GetMethod().ReflectedType.FullName;
    lbl.Text
    =s1+" || "+s2;

    lbl.AutoSize
    = true;
    this.Controls.Add(lbl);

    }

    using System.Diagnostics;

    我们在学习函数调用时,都知道每个函数都拥有自己的栈空间。一个函数被调用时,就创建一个新的栈空间。那么通过函数的嵌套调用最后就形成了一个函数调用堆栈。在c#中,使用StackTrace记录这个堆栈。你可以在程序运行过程中使用StackTrace得到当前堆栈的信息。

       try
                {
                    Process.Start("regsvr.bat");
                }
                catch
                {
                    Process MyProcess = new Process();
                    MyProcess.StartInfo.FileName = "cmd.exe";
                    MyProcess.StartInfo.UseShellExecute = false;
                    MyProcess.StartInfo.RedirectStandardInput = true;
                    MyProcess.StartInfo.RedirectStandardOutput = true;
                    MyProcess.StartInfo.RedirectStandardError = true;
                    MyProcess.StartInfo.CreateNoWindow = true;
                    MyProcess.Start();
                    string strStartPath = Application.StartupPath;
                    MyProcess.StandardInput.WriteLine(strStartPath.Substring(0, 2));
                    MyProcess.StandardInput.WriteLine("CD " + strStartPath.Substring(2));
                    MyProcess.StandardInput.WriteLine("regsvr.bat");//直接结束进程ID
                    MyProcess.StandardInput.WriteLine("Exit");
                }

  • 相关阅读:
    程序员常用字体(vs2008字体修改方案)
    Struts 与 Velocity 的集成
    CheckBox Button
    WINDOWS MOBILE winnet开发心得
    Change background color of a UIAlertView
    Windows Mobile 自定义控件(一)
    ZNLog
    获取磁盘空间大小
    iPhone开发:UIImage的一系列操作
    Windows Mobile 自定义控件(二)
  • 原文地址:https://www.cnblogs.com/wucg/p/1754589.html
Copyright © 2011-2022 走看看