Skip to content
Snippets Groups Projects
Commit 78e961fb authored by blackoverlord's avatar blackoverlord
Browse files

updated readme

parent 56fb01bd
No related branches found
No related tags found
No related merge requests found
......@@ -11,10 +11,10 @@ This library allows you create new and read and modify existing .lnk files. It c
* extra data blocks: Darwin, IconEnvironment, KnownFolder, PropertyStore, Shim, SpecialFolder
* some options in LinkTargetIDList because this section is not documented
* environment variables: you can use it in target path but it resolves while creating link and not stored in the lnk file (the reason is previous item)
* environment variables: you can use it in target path but it resolves while creating link and not stored in the lnk file
### Examples
Easiest way to create link with default parameters: `ShellLink.createLink("targetfile", "linkfile.lnk")`
Easiest way to create link with default parameters: `ShellLinkHelper.createLink("targetfile", "linkfile.lnk")`
Following example demonstrates creating link for .bat file and setting working directory, icon and setting up font parameters for console
```
......@@ -24,8 +24,8 @@ import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
ShellLink sl = ShellLink.createLink("pause.bat")
.setWorkingDir("..")
var sl = new ShellLink()
.setWorkingDir(Paths.get("..").toAbsolutePath().normalize().toString())
.setIconLocation("%SystemRoot%\\system32\\SHELL32.dll");
sl.getHeader().setIconIndex(128);
sl.getConsoleData()
......@@ -33,15 +33,19 @@ public class Main {
.setFontSize(24)
.setTextColor(5);
sl.saveTo("testlink.lnk");
System.out.println(sl.getWorkingDir());
System.out.println(sl.resolveTarget());
Path targetPath = Paths.get("pause.bat").toAbsolutePath();
String root = targetPath.getRoot().toString();
String path = targetPath.subpath(0, targetPath.getNameCount()).toString();
new ShellLinkHelper(sl)
.setLocalTarget(root, path, Options.ForceTypeFile)
.saveTo("testlink.lnk");
}
}
```
Final example creates cyclic link that blocks explorer on Windows 7 while trying to get into the containing directory
Final example creates cyclic link that blocks explorer on Windows 7 when trying to get into the containing directory
```
package mslinks;
......@@ -49,13 +53,20 @@ import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
ShellLink sl = ShellLink.createLink("test.lnk");
var sl = new ShellLink();
sl.getHeader().getLinkFlags().setAllowLinkToLink();
sl.saveTo("test.lnk");
Path targetPath = Paths.get("test.lnk").toAbsolutePath();
String root = targetPath.getRoot().toString();
String path = targetPath.subpath(0, targetPath.getNameCount()).toString();
new ShellLinkHelper(sl)
.setLocalTarget(root, path, Options.ForceTypeFile)
.saveTo("testlink.lnk");
}
}
```
### Download
* [releases page](https://github.com/BlackOverlord666/mslinks/releases)
* [releases page](https://github.com/DmitriiShamrikov/mslinks/releases)
* [Maven Central Repository](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.vatbub%22%20AND%20a%3A%22mslinks%22)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment