从 asp.net 运行一个网站,我需要将控制(焦点)转移到 winforms 应用程序。
如果应用程序没有运行,我知道我可以使用 process.start() 方法。
但如果应用程序正在运行,我不想启动新窗口。
我可以选择将 winform 应用程序设置为唯一实例,但如果它是外部应用程序怎么办?我的意思是,如果我不是作者并且无法控制启动新实例...
我如何在客户端计算机上找到给定的窗口并从 ASP.NET 激活它
Running a website from asp.net, I need to transfer control (focus) to a winforms application.
In case the application isn't running, I know I can use process.start() method.
But in case the application is running, I don't want to launch a new window.
I have the option to setup the winform application as unique instance, but what if it is a foreign application? I mean if I'm NOT the author and have no control over launching new instances...
How can I find a given window on the client computer and activate it from ASP.NET
发布评论
评论(3)
由于安全原因,您不能这样做。浏览器内的代码无权访问用户系统。
Due to security reasons you cannot do it. Code inside browser doesn't have access to user system.
如果浏览器是 Internet Explorer,您可以托管 .Hta 页面(或返回内容类型:application/hta )。
.Hta 页面是完全受信任的,可以通过 COM 访问本地计算机上的所有内容。因此,如果您可以使用 VBScript 完成此操作,则可以在 .Hta 页面中完成此操作。
用户在下载之前必须信任该“应用程序”。如果这是一个互联网应用程序,您可能不会得到这种信任。如果这是 Intranet 应用程序,您可以强制用户信任该页面。
If the browser is Internet Explorer, you could host a .Hta page (or return a content type: application/hta ).
A .Hta page is fully trusted, and can access everything on your local machine through COM. So if can you do it with VBScript, you can do it in a .Hta page.
The user has to trust this "application" before it is downloaded. If this is an Internet application you will probably not get this trust. If this is an Intranet application, you can force the user to trust the page.
我想如果这是您真正需要的一些功能,您可以沿着 ActiveX 路线走。话虽如此,它只能在 IE 中运行,并且需要一个单独的插件才能让 firefox(或其他兄弟)运行。
老实说,这对于你想要实现的目标来说听起来有点矫枉过正。
I suppose if this was a bit of functionality you really needed you could go down the ActiveX route. Having said that it would only work in IE and would require a separate plugin for firefox (or other brothers) to function.
Honestly though it sounds like overkill for what you are trying to achieve.