File icon overlay in java for windows

情到浓时终转凉″ 提交于 2019-12-05 22:55:56

问题


I am trying to implement icon overlaying on files and folders just like Tortoise SVN or Dropbox does.

I did a lot of searching on the Internet, but I cannot find a solution in Java.

Can anyone help me with this?


回答1:


I am sorry to confirm your fears, but it can't be done in Java.

Since the Windows Explorer is the one in control, Icon Overlay is sort of a plug-in. It has to be implemented as a DLL (not a JNI but a true native DLL), and registered in the Windows Registry. As you saw in CodeProject article, your DLL has to implement specific interface - IShellIconOverlayIdentifier.

Take for example the TortoiseSVN implementation.

TortoiseSVN's DLL is loaded by the Explorer and attached to its process:

DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */)
{
  ...
  if (dwReason == DLL_PROCESS_ATTACH)
  ...

In order to do this in Java you would need to write a DLL that would load the JVM and your JAR which would be an overkill.

As for the Tray Icon overlay, your Java application is the one in control so it can be done.




回答2:


I had the same problem and just found a solution for Java 1.7+ in combination with native and jni dlls. Works with Windows Vista+, Mac and Linux.

You can find the GIT project here: https://github.com/liferay/liferay-nativity

See my SO question here: Method to implement Windows Explorer icon overlays with Java



来源:https://stackoverflow.com/questions/9842530/file-icon-overlay-in-java-for-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!