简体   繁体   English

将Windows资源管理器上下文菜单(右键菜单)的FilePath获取到Java

[英]Get FilePath of Windows Explorer Context Menu (Right-click menu) to Java

let's suppose that I have created and added a new entry to the Windows explorer right-click menu (context menu) by adding a registry entry that points to a .exe written in C++ that just reads and returns the filename of the clicked file. 让我们假设我通过添加一个注册表项来创建并向Windows资源管理器的右键单击菜单(上下文菜单)添加了一个新条目,该注册表项指向用C ++编写的.exe,该文件仅读取并返回所单击文件的文件名。

Is it possible to get this filename to an already running Java app? 是否可以将此文件名获取到已经运行的Java应用程序?

I thought of using JNI but is it possible to call a method of an already running Java app from a native C++ program? 我曾考虑过使用JNI,但是否可以从本地C ++程序调用已经运行的Java应用程序的方法?

Does anybody have another idea how to solve this? 有人有另一个想法如何解决这个问题吗? Is it possible to have a pure Java solution? 是否可以有一个纯Java解决方案?

Many thanks. 非常感谢。

Edit: Is it possible to call an existing method of an already running JVM? 编辑:是否可以调用已经运行的JVM的现有方法? Then I could create a C++ program that listen for right-clicks and register that .exe with a registry entry for the contextmenu. 然后,我可以创建一个侦听右键单击的C ++程序,并使用上下文菜单的注册表项注册该.exe。 Inside the C++ program, I could call a dll that injects into an already running JVM. 在C ++程序内部,我可以调用一个DLL,该DLL注入已经运行的JVM中。 The dll could call a Java method and commits the clicked filepath to Java. dll可以调用Java方法,并将单击的文件路径提交到Java。 Would that be a possibility? 那有可能吗?

You could connect to an already running Java program through a socket connection, or store values to a database of some kind that both your C++ application and Java application can access. 您可以通过套接字连接连接到已经运行的Java程序,或者将值存储到C ++应用程序和Java应用程序都可以访问的某种数据库中。

Besides my suggestions, here's a stackoverflow post that talks about communicating to a Java program already running without the Java program making the initial communication . 除了我的建议之外, 这里还有一个stackoverflow帖子,其中讨论了与已经运行的Java程序进行通信而无需Java程序进行初始通信

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM