zoukankan      html  css  js  c++  java
  • C# 中运行exe程序

     private int runProcess(string fileName, string appParam)
            {
                int returnValue = -1;
                try
                {
                    Process myProcess = new Process();
                    ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(fileName, appParam);
                    myProcessStartInfo.CreateNoWindow = true;
                    myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    myProcess.StartInfo = myProcessStartInfo;
                    myProcess.Start();
    
                    while (!myProcess.HasExited)
                    {
                        myProcess.WaitForExit();
                    }
    
                    returnValue = myProcess.ExitCode;
                    myProcess.Dispose();
                    myProcess.Close();
    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                return returnValue;
            }
    

     1、启动*.exe程序

     
      System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.Arguments = String.Format("{0} {1} {2}", columnStr, tempFilePath, "True"); startInfo.FileName = this.applicationPath + "\Excel.exe"; startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = startInfo;
       process.Start();   
       process.WaitForExit(); process.Close();

     2、调用外部程序

            private void CallOutProcess(string s文件名)
            {
                System.Diagnostics.ProcessStartInfo pinfo = new System.Diagnostics.ProcessStartInfo();
                pinfo.UseShellExecute = true;
                pinfo.FileName = s文件名;
                //启动进程
                System.Diagnostics.Process p = System.Diagnostics.Process.Start(pinfo);
            }
    
  • 相关阅读:
    Mysql安装(msi版的安装)
    001 springBoot的数据库操作
    使用IDEA搭建spring
    spring简介
    rabbitMQ的安装(Windows下)
    mysql过滤数据
    mysql查询数据
    均值滤波,中值滤波,最大最小值滤波
    图像运动去模糊(Motion Deblurring)代码
    数字图像处理,图像锐化算法的C++实现
  • 原文地址:https://www.cnblogs.com/shenchao/p/3556466.html
Copyright © 2011-2022 走看看