Creating a shortcut file from Java

后端 未结 2 781
名媛妹妹
名媛妹妹 2020-12-19 03:20

One problem which has been puzzling me for weeks now is how I can create a shortcut file from Java. Now before I say anything else, I have looked all over Google (and also o

相关标签:
2条回答
  • 2020-12-19 03:50

    http://www.mindfiresolutions.com/Creating-shortcut-from-a-Java-Application-1712.php

    A nice and simple tutorial to use a jni using library called jShellLink

    0 讨论(0)
  • 2020-12-19 04:02

    I can recommend this repository on GitHub:

    https://github.com/BlackOverlord666/mslinks

    There I've found a simple solution to create shortcuts:

    ShellLink.createLink("path/to/existing/file.txt", "path/to/the/future/shortcut.lnk");

    If you want to read shortcuts:

    File shortcut = ...;
    String pathToExistingFile = new ShellLink(shortcut).resolveTarget();
    

    If you want to change the icon of the shortcut, use:

    ShellLink sl = ...;
    sl.setIconLocation("/path/to/icon/file");
    

    Hope this helps you :)

    Kind regards

    Josua Frank

    0 讨论(0)
提交回复
热议问题