1、这种方法在开发环境下可以实现,但是发布到IIS后不可以
[DllImport("shell32.dll ")]
public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile,StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
public ActionResult Test(string sJH)
{
//ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder("D:\\11\\DNCS.CJTest.exe"),
// new StringBuilder("123123123123123" + " " + "admin"), new StringBuilder(""), 1);
//new StringBuilder(DSU.ID + " " +DSU.USER_LOGINNAME), new StringBuilder(""), 1);
//Process process = new Process();
//process.StartInfo.UseShellExecute = false;
//process.StartInfo.CreateNoWindow = false;
//process.StartInfo.FileName = "D:\\11\\DNCS.CJTest.exe";
//process.Start();
return this.Direct();
}
调用方式
<a href="DNCS://cid:110&username:xxh">点击这里启动程序</a>
注册表文件
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\DNCS]
"URL Protocol"="D:\\11\\DNCS.LJFileUpload.exe"
@="DNCSProtocol"
[HKEY_CLASSES_ROOT\DNCS\DefaultIcon]
@="D:\\11\\DNCS.LJFileUpload.exe,1"
[HKEY_CLASSES_ROOT\DNCS\shell]
[HKEY_CLASSES_ROOT\DNCS\shell\open]
[HKEY_CLASSES_ROOT\DNCS\shell\open\command]
@="\"D:\\11\\DNCS.LJFileUpload.exe\" \"%1\""