在Java中,如何从Windows的上下文菜单中读取文件名

发布于 2024-09-15 10:15:52 字数 223 浏览 1 评论 0原文

我是新来的,在 Java 编程中,我正在尝试编写一个程序,该程序可以使用上下文菜单命令并读取文件名及其完整

路径 当我在某个文件上单击(鼠标右键)并获取上下文菜单并选择任何选项(复制、发送到或打开方式)时 我希望我的程序能够读取文件名和他的完整路径。

现在我只有一个带有文本框的表单,还没有代码。

我想知道我应该如何开始,或者是否有人有想法或代码来帮助我,

非常感谢!

I'm new here and in Java programing I'm trying to write program that cath the context menu command and read the file name and his full path

for example
when I'm clicking (right mouse) on some file and getting the context menu and I selecting any option (copy, or send to, or open with)
I want that my program will read the file name and his full path.

for now I just have a form with text box , no code yet.

I want to know how should I start or if some one have Idea or code to help me with that

Thanx alot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や三分注定 2024-09-22 10:15:53

这很简单:

在您的程序中,main 方法必须是这种类型:

public static void main(String[] args) { ... }

在 Eclipse 中,您可以将其导出为可运行的 jar。 打开“发送到”菜单

shell:sendto

现在,通过资源管理器窗口 。在那里,放置一个快捷方式。您正在寻找的快捷方式是

java -jar C:\path\to\jar\main.jar

请注意,您必须能够为此运行您的应用程序。

当您这样做时,sendto-filename 将出现在程序的 args 参数中。

It's quite simple:

In your program, the main method has to be of this kind:

public static void main(String[] args) { ... }

In Eclipse, you can export this as a runnable jar. Now, open the sendto menu via

shell:sendto

in your explorer window. In there, put a shortcut. The shortcut you are looking for is

java -jar C:\path\to\jar\main.jar

Be aware that you have to be able to run your application for that.

When you do that, the sendto-filename will appear in the args parameters in your program.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文