如何在 Web 应用程序中从 activex 将参数传递给 exe(windows 表单应用程序)?
How to pass parameter to an exe (windows form application) from activex in web application?
我有一份 windows 表格申请。我已将其转换为一个设置并使用 activeX
从 Web 应用程序调用其 exe 文件,如下所示:-
var executableFullPath = "C:\ScannerExeFile\Scannerapplication.exe";
var shellActiveXObject = new ActiveXObject("WScript.Shell");
shellActiveXObject.Run(executableFullPath,1, false);
shellActiveXObject = null;
现在我想将字符串参数传递给 windows 表单 application.Can 有人帮我吗?
您需要像这样在 ActiveX 对象中使用 PARAM 标记:
<OBJECT classid="clsid:959B7E21-6C0B-3BEC-BA2E-48DA2B6D83K5">
<PARAM NAME="Id" VALUE="2">
</OBJECT>
我得到 answer.The 代码如下:-
var executableFullPath = "C:\ScannerExeFile\Scannerapplication.exe param1 param2 param3";
var shellActiveXObject = new ActiveXObject("WScript.Shell");
shellActiveXObject.Run(executableFullPath,1, false);
shellActiveXObject = null;
在windows应用程序中,您应该将Program.cs中的主函数编辑为
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if(args!=null && args.Length>0)
Application.Run(new Scanner(args));
else
Application.Run(new Scanner(args));
}
}
在class中,你应该改变构造函数如下:-
public Scanner(string[] args)
{
Arguments = args;
InitializeComponent();
}
其中 Arguments 是一个字符串数组
private string[] Arguments;
我有一份 windows 表格申请。我已将其转换为一个设置并使用 activeX
从 Web 应用程序调用其 exe 文件,如下所示:-
var executableFullPath = "C:\ScannerExeFile\Scannerapplication.exe";
var shellActiveXObject = new ActiveXObject("WScript.Shell");
shellActiveXObject.Run(executableFullPath,1, false);
shellActiveXObject = null;
现在我想将字符串参数传递给 windows 表单 application.Can 有人帮我吗?
您需要像这样在 ActiveX 对象中使用 PARAM 标记:
<OBJECT classid="clsid:959B7E21-6C0B-3BEC-BA2E-48DA2B6D83K5">
<PARAM NAME="Id" VALUE="2">
</OBJECT>
我得到 answer.The 代码如下:-
var executableFullPath = "C:\ScannerExeFile\Scannerapplication.exe param1 param2 param3";
var shellActiveXObject = new ActiveXObject("WScript.Shell");
shellActiveXObject.Run(executableFullPath,1, false);
shellActiveXObject = null;
在windows应用程序中,您应该将Program.cs中的主函数编辑为
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if(args!=null && args.Length>0)
Application.Run(new Scanner(args));
else
Application.Run(new Scanner(args));
}
}
在class中,你应该改变构造函数如下:-
public Scanner(string[] args)
{
Arguments = args;
InitializeComponent();
}
其中 Arguments 是一个字符串数组
private string[] Arguments;