使用Java打开文件的属性窗口 [英] Open a file's properties window using Java

查看:62
本文介绍了使用Java打开文件的属性窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这只是Windows中有关Java的问题.

This is a question only regarding Java in Windows.

我需要一个可以调用此窗口的方法:

I need a method that will call this window:

因此,基本上该方法应类似于:

So essentially the method should be something like:

public void openProperties(File file){ // or String fileName

}

因此,语句: opernProperties(new File(test.txt)); 应该打开上面的窗口.

So the statement: opernProperties(new File(test.txt)); should open the above window.

因此,为了澄清起见,我不想阅读和管理属性.我只想打开属性窗口.

So just to clarify, I do not want to read and manage the properties. I just want to open the properties window.

推荐答案

我能够使用以下命令显示文件属性窗口:

I was able to display the file properties window using the following:

这将显示属性窗口,并延迟3秒.请注意,如果您不希望窗口在3秒后自动关闭,则alk讨论过将窗口传递给hwnd成员

This should display the properties window with a delay of 3 seconds. Notice that alk talked about passing the window through hwnd member if you don't want it to auto close after the 3 seconds

public static void main(String[] args) throws InterruptedException {
        ShellAPI.SHELLEXECUTEINFO shellExecuteInfo = new ShellAPI.SHELLEXECUTEINFO();
        shellExecuteInfo.lpFile = "C:\\setup.log";
        shellExecuteInfo.nShow = User32.SW_SHOW;
        shellExecuteInfo.fMask = 0x0000000C;
        shellExecuteInfo.lpVerb = "properties";
        if (Shell32.INSTANCE.ShellExecuteEx(shellExecuteInfo)){
            Thread.sleep(3000);
        }
    }

这篇关于使用Java打开文件的属性窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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