jshortcut用于创建桌面快捷方式及相关内容,使用此jar包时,需要导入jshortcut.dll文件,不然会出现exception。具体导入dll文件详见百度经验:http://jingyan.baidu.com/article/2f9b480d96ce8741ca6cc249.html
需要注意jshortcut.dll分x86/x64,不要放错了(话说,x64的dll我找了好久才找到)
使用方法如下:
private void createShortcut() {
// 获取系统桌面路径
String desktop = FileSystemView.getFileSystemView().getHomeDirectory()
.getAbsolutePath();
// 程序执行文件路径
String path = System.getProperty("user.dir") + "\\appName.exe";
JShellLink link = new JShellLink();
link.setFolder(desktop); // 快捷方式存放地址
link.setName("appName"); // 快捷方式名称
link.setPath(path); // 快捷方式指向地址
link.save();
}
-----------------------------------------------------------------------------------
带参数
public static void createShortCut(String fileorFolderPath, String writeShortCutPath, String arguments){
JShellLink link=new JShellLink();
writeShortCutPath=writeShortCutPath.replaceAll("/", "\\");
String folder=writeShortCutPath.substring(0, writeShortCutPath.lastIndexOf("\\")+1);
String name=writeShortCutPath.substring(writeShortCutPath.lastIndexOf("\\")+1,
writeShortCutPath.length());
link.setName(name);//目标快捷方式文件夹名称
link.setFolder(folder);//目的快捷方式文件路径片段
link.setPath(fileorFolderPath);
if(arguments != null && !"".equals(arguments.trim())){
link.setArguments(arguments);
}
link.save();
}
---------------------------------------------------------------------------------
import net.jimmc.jshortcut.JShellLink;
/**
* 快捷方式工具类
*
* @author ice(古雨QQ:494174519,13728989948(你的代码改进,是对我们共同的鼓励))
*
*/
public class ShortCut {
// 需要先下载jshortcut.jar直接在百度搜一下
public static void main(String args[]) {
String fileFolderPath = "D:\\test\\jshortcut-0_4.jar";
String writeFolderPath = "D:\\new";
createShortCut(fileFolderPath, writeFolderPath);
String path=getShortCutRealPath(writeFolderPath);
System.out.println(path);
}
/**
* 创建一个快捷方式
*
* @param fileOrFolderPath
* 源文件夹路径
* @param writeShortCutPath
* 目标文件路径(快捷方式型)
*/
public static void createShortCut(String fileOrFolderPath,String writeShortCutPath) {
JShellLink link = new JShellLink();
writeShortCutPath.replaceAll("/", "\\");
String folder = writeShortCutPath.substring(0, writeShortCutPath.lastIndexOf("\\"));
String name = writeShortCutPath.substring(writeShortCutPath.lastIndexOf("\\") + 1, writeShortCutPath.length());
link.setName(name);// 目的快捷方式文件夹名称
link.setFolder(folder);// 目的快捷方式文件路径片段
link.setPath(fileOrFolderPath);
link.save();
}
/**
* 获取一个快捷方式真实地址
*
* @param fileFolderPath
* 源文件夹路径
*/
public static String getShortCutRealPath(String fileFolderPath) {
// 根据快捷方式的路径和文件夹名,获取源文件夹地址
fileFolderPath.replaceAll("/", "\\");
String folder = fileFolderPath.substring(0, fileFolderPath.lastIndexOf("\\"));
String name = fileFolderPath.substring(fileFolderPath.lastIndexOf("\\") + 1, fileFolderPath.length());
JShellLink link = new JShellLink(folder, name);
link.load();
return link.getPath();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jshortcut.jar jshortcut.dll x64 x86,api,例子
共20个文件
html:13个
dll:2个
txt:1个
5星 · 超过95%的资源 需积分: 39 166 下载量 119 浏览量
2016-04-21
11:36:13
上传
评论
收藏 173KB RAR 举报
温馨提示
jshortcut用于创建桌面快捷方式及相关内容,使用此jar包时,需要导入jshortcut.dll文件,不然会出现exception。具体导入dll文件详见百度经验:http://jingyan.baidu.com/article/2f9b480d96ce8741ca6cc249.html 需要注意jshortcut.dll分x86/x64,不要放错了
资源推荐
资源详情
资源评论
收起资源包目录
jshortcut.rar (20个子文件)
jshortcut
x86_dll
jshortcut.dll 57KB
jshortcut.jar 2KB
api
package-list 20B
deprecated-list.html 4KB
help-doc.html 7KB
allclasses-frame.html 706B
index.html 702B
allclasses-noframe.html 696B
stylesheet.css 1KB
constant-values.html 4KB
net
jimmc
jshortcut
package-summary.html 5KB
package-frame.html 856B
package-tree.html 4KB
JShellLink.html 21KB
index-all.html 10KB
packages.html 665B
overview-tree.html 4KB
demo.zip 108KB
jshortcut说明.txt 4KB
x64_dll
jshortcut.dll 61KB
共 20 条
- 1
dl348
- 粉丝: 9
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页