在JFrame中运行可执行文件(.exe) [英] Running an executable (.exe) within a JFrame

查看:98
本文介绍了在JFrame中运行可执行文件(.exe)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用Java开发一个项目,我们必须使用别人创建的头像.该头像是图形可执行文件.它通过xmlrpc与Java应用程序进行通信.

I am currently working on a project in Java where we have to use an avatar created by someone else. This avatar is a graphical executable. It communicates with the Java application through xmlrpc.

我希望能够在我的Java应用程序中运行(嵌入)此可执行文件.我不仅要执行可执行文件,还希望它实际上在Java应用程序中可见.

I want to be able to run (embed) this executable within my Java application. I don't just want to execute the executable, I want it to actually be visible within the Java application.

我知道这种行为在C#(Process类)中是可能的,所以我想知道:在Java中也可能吗?

I know this behavior is possible in C# (Process class), so I was wondering: is this also possible in Java?

应用程序中的头像必须是可伸缩的.

The avatar in the application must be scalable.

推荐答案

Win32使用

The C# example you gave uses a Win32 API trick that uses SetParent to change the parent of the running embedded executable's main window from the desktop window to a newly created control. In order to do that, you would need to :

  • Create a WinAPI Window control to contain your embedded executable
  • Have access to the Windows API to get a handle on the running .exe main window
  • Have access to the Windows API to use SetParent

问题是您无权使用Java访问Windows API .甚至使用 JNI 或类似

The problem is that you don't have access to the Windows API in Java. And even using JNI or something like JNA that would'nt be easy to do so since you don't have direct access to the WinAPI Window control created by the JVM (except using some undocumented windows-specific Sun API).

这篇关于在JFrame中运行可执行文件(.exe)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆