0

This is a question only regarding Java in Windows.

I need a method that will call this window:

enter image description here

So essentially the method should be something like:

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

}

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.

nick zoum
  • 7,216
  • 7
  • 36
  • 80
  • This question was already asked without an answer [http://stackoverflow.com/questions/11132939/how-to-show-properties-window-of-native-file-systems-file-folder-in-java](http://stackoverflow.com/questions/11132939/how-to-show-properties-window-of-native-file-systems-file-folder-in-java) – Tzach Solomon Sep 14 '16 at 10:49
  • I think your best option is to use [java native access](https://github.com/java-native-access) and than try to use the following code [http://stackoverflow.com/a/33472984/1866870](http://stackoverflow.com/a/33472984/1866870) – Tzach Solomon Sep 14 '16 at 11:03

2 Answers2

2

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

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);
        }
    }
Tzach Solomon
  • 688
  • 8
  • 27
0

The Windows API call SHObjectProperties will also launch Windows file property dialog. You could call from JNA, JNI or try JDK Panama / Foreign Memory API available as incubator in JDK16 or above.

DuncG
  • 12,137
  • 2
  • 21
  • 33