How to launch the default (native) application for a given file from Java?
What you want is java.awt.Desktop: Desktop.getDesktop().open( file );
What you want is java.awt.Desktop: Desktop.getDesktop().open( file );
I have written a library that might be able to help you. You could use the controls provided by the library, or if you don’t want to do that, looking through the code may give you an answer. You can find the library at: http://gong-shell.sourceforge.net/ Please let me know if this helped!
Does anyone have any ideas how to do this better? Personally I don’t know. You mention the Tortoise programs which do a similar thing, so an excellent starting point would be to have a look at what they do in their source 🙂 These look to be the relevant source files that handle this problem: … Read more
I debugged this out of curiosity. All it does is post a message to one of explorer’s windows: BOOL ExitExplorer() { HWND hWndTray = FindWindow(_T(“Shell_TrayWnd”), NULL); return PostMessage(hWndTray, 0x5B4, 0, 0); } Of course this is an undocumented WM_USER message so the behavior could quite possibly change in the future.
Disclaimer: I tested all of these myself on Windows 10. I could not find an authoritative source documenting all of these behaviours. It is entirely possible that I made a mistake somewhere. The folder’s last modified time is updated for these actions: new file or folder directly in target folder renamed file or folder directly … Read more
After parsing some of the earlier answers and doing a bit of research, I’ve created a little complete example in C#. This closes the explorer shell then waits for it to completely shut down and restarts it. Hope this helps, there’s a lot of interesting info in this thread. using System; using System.Collections.Generic; using System.Linq; … Read more
It’s pretty straight-forward, just call DoDragDrop in a MouseDown event. You’ll need actual files on disk for this to work. private void Form1_MouseDown(object sender, MouseEventArgs e) { string[] files = new string[] { @”c:\temp\test.txt” }; this.DoDragDrop(new DataObject(DataFormats.FileDrop, files), DragDropEffects.Copy); }
This is my second try to answer this. I used http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting as a start. Unfortunatly I think I found there problems as well. But I think in my code these problems are correctly adressed. Info: Windows Explorer uses the API function StrCmpLogicalW() function to do its sorting. There it is called natural sort order. So … Read more
This should be possible with the shell function SHOpenFolderAndSelectItems EDIT Here is some sample code showing how to use the function in C/C++, without error checking: //Directory to open ITEMIDLIST *dir = ILCreateFromPath(_T(“C:\\”)); //Items in directory to select ITEMIDLIST *item1 = ILCreateFromPath(_T(“C:\\Program Files\\”)); ITEMIDLIST *item2 = ILCreateFromPath(_T(“C:\\Windows\\”)); const ITEMIDLIST* selection[] = {item1,item2}; UINT count = … Read more
Associate the “.rb” file extension with the ruby interpreter. On Windows XP, one way to do this is to select “Tools|Folder options” in the file explorer, and to setup the association in the “File types” tab. Another way would be to enter the following on the commandline which creates this file association for you: assoc … Read more