java:如何设置本机.exe的兼容模式?
因此,我有一个本机可执行文件(适用于 OS X 和 Windows)隐藏在 .jar 中,然后以编程方式将其提取到临时位置并从那里执行。不幸的是,这个可执行文件无法在我的 Windows 计算机(Win 7 64 位)上正常运行,但是当我手动将兼容模式设置为 Windows XP 预设时,它会工作。
有没有办法可以通过 Java 以编程方式执行此操作?
So i have a native executable (both for OS X and Windows) tucked inside a .jar, which is then programatically extracted to a temp location and executed from there. Unfortunately this executable will not run properly on my Windows machine (Win 7 64bit), when i manually set the compatibility mode to a Windows XP preset however, it will work.
Is there a way i can do this programatically from Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信有一种方法可以通过更改注册表来做到这一点,因此您必须使用 Java 以编程方式更改某些注册表项。当然,这不是一个理想的解决方案,也绝对不是一个跨平台的解决方案。
以下是如何操作 实现这一目标。
另外,您还需要一个利用 Windows API 的 Java 包,快速 Google 搜索就会发现 这个。但我确信还有更多方法可以访问注册表。
I believe there is a way to do this by changing the registry, so you will have to use Java to programmatically change some registry keys. This is not an ideal solution of course and definitely not a cross-platform one either.
Here's the link on how to achieve that.
Also, you'll want a Java package that utilizes the Windows API, a quick Google search reveals this. But I'm sure there are more ways to access the registry.
我认为您确实想修复本机 exe 中的不兼容性。兼容模式实际上适用于用户没有选择的应用程序。我无法告诉你我浪费了多少时间来调试由于用户意外打开兼容模式而导致的愚蠢行为 - 如果你在这件事上有任何选择,最好避免它。
I'd think that you'd really want to fix the incompatibility in your native exe. Compatibility mode is really for apps where the user just doesn't have a choice. I can't tell you how many hours I've wasted debugging goofy behavior caused by the user accidentally turning compatibility mode on - best to avoid it if you have any choice in the matter.