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");
                }

  • 相关阅读:
    iOS 表单 application/x-www-form-urlencoded
    iOS WebRTC
    静态库文件
    .crash 文件解析
    UIWebView转WKWebView,与前端交互的问题
    App Technical Support
    关于URL转义问题
    关于iOS架构相关的博客
    Mac Jenkins
    零碎知识点
  • 原文地址:https://www.cnblogs.com/wucg/p/1754589.html
Copyright © 2011-2022 走看看