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 }
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.
Advertisement
Answer
I was able to display the file properties window using the following:
- Go to https://oss.sonatype.org/content/repositories/snapshots/net/java/dev/jna/
- Download the snapshot JARs jna-4.3.0-20160510.203907-1.jar and jna-platform-4.3.0-20160510.204004-1.jar (We can’t use the latest version that is located at maven repo since it’s 4.2.2 and it does not have the SHELLEXECUTEINFO)
- Load the jars and paste the following code below
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); } }