ASP.NET中调用EXE程序

来源:互联网 发布:java orm 轻量级 编辑:程序博客网 时间:2024/05/17 04:46

using System.Diagnostics;
using System.ComponentModel;

 

public partial class _Default : System.Web.UI.Page
{
    const int ERROR_FILE_NOT_FOUND = 2;

 

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Process proc = new Process();
        try
        {

            proc.StartInfo.FileName = @"E:\tools\GPU-Z.0.2.6.exe";
            proc.StartInfo.Arguments = "";
            proc.Start();
        }
        catch (Win32Exception ex)
        {
            if (ex.NativeErrorCode == ERROR_FILE_NOT_FOUND)
            {
                Response.Write("<script>alert('" + ex.Message + "') </script>");
            }
           
        }

        //Process.Start("E:\\tools\\GPU-Z.0.2.6.exe");
    }
}

0 0
原创粉丝点击